Johny Mattsson 9bbf8f43fb Successfully boot barebones NodeMCU on ESP32 (only).
RTOS driver evicted as it did not play nice with stdio etc.

Implemented a minimal driver to fully support Lua console on UART0. Output
on UART0 done via stdout (provided by the IDF). Input and setup handled
via driver_console/console.c. In addition to the direct input function
console_getc(), the driver also registers in the syscall tables to enable
regular stdio input functions to work (yay!). The Lua VM is still using the
direct interface since it's less overhead, but does also work when going
through stdin/fd 0.

Auto-bauding on the console is not yet functional; revisit when the UART docs
are available.

Module registration/linking/enabling moved over to be Kconfig based. See
updates to base_nodemcu/include/module.h and base_nodemcu/Kconfig for
details.

The sdk-overrides directory/approach is no longer used. The IDF is simply
too different to the old RTOS SDK - we need to adapt our code directly instead.

Everything in app/ is now unused, and will need to be gradually migrated
into components/ though it is probably better to migrate straight from the
latest dev branch.
2016-09-20 13:35:56 +10:00

60 lines
1.7 KiB
C

#ifndef _CPU_ESP32_H_
#define _CPU_ESP32_H_
#include "sdkconfig.h"
#include "esp_spi_flash.h"
#define NUM_UART 3
#if defined(CONFIG_FLASH_SIZE_512K)
# define FLASH_SEC_NUM 0x80 // 4MByte: 0x400, 2MByte: 0x200, 1MByte: 0x100, 512KByte: 0x80
#elif defined(CONFIG_FLASH_SIZE_1M)
# define FLASH_SEC_NUM 0x100
#elif defined(CONFIG_FLASH_SIZE_2M)
# define FLASH_SEC_NUM 0x200
#elif defined(CONFIG_FLASH_SIZE_4M)
# define FLASH_SEC_NUM 0x400
#elif defined(CONFIG_FLASH_SIZE_8M)
# define FLASH_SEC_NUM 0x800
#elif defined(CONFIG_FLASH_SIZE_16M)
# define FLASH_SEC_NUM 0x1000
#elif defined(CONFIG_FLASH_SIZE_AUTO)
# if defined(FLASH_SAFE_API)
# define FLASH_SEC_NUM (flash_safe_get_sec_num())
# else
# define FLASH_SEC_NUM (flash_rom_get_sec_num())
# endif // defined(FLASH_SAFE_API)
#else
# define FLASH_SEC_NUM 0x80
#endif
#define SYS_PARAM_SEC_NUM 4
#define SYS_PARAM_SEC_START (FLASH_SEC_NUM - SYS_PARAM_SEC_NUM)
#define INTERNAL_FLASH_SECTOR_SIZE SPI_FLASH_SEC_SIZE
#define INTERNAL_FLASH_WRITE_UNIT_SIZE 4
#define INTERNAL_FLASH_READ_UNIT_SIZE 4
#define INTERNAL_FLASH_SIZE ( (SYS_PARAM_SEC_START) * INTERNAL_FLASH_SECTOR_SIZE )
#define IROM0_START_MAPPED_ADDR 0x3F400000
// TODO: tie this in with the partition table!
#define IROM0_START_FLASH_ADDR 0x40000
// TODO: might need to revamp all this once cache windows fully understood
#define INTERNAL_FLASH_MAPPED_ADDRESS IROM0_START_MAPPED_ADDR
#if defined(FLASH_SAFE_API)
#define flash_write flash_safe_write
#define flash_erase flash_safe_erase_sector
#define flash_read flash_safe_read
#else
#define flash_write spi_flash_write
#define flash_erase spi_flash_erase_sector
#define flash_read spi_flash_read
#endif // defined(FLASH_SAFE_API)
#endif