Table of Contents
This documentation is part of the MicroPython project, http://micropython.org/
These MBOOT_* macros have been scanned from the source code in the MicroPython repository. The descriptions for each macro have been generated based on the surrounding code context using the OpenAI o3-mini model.
MBOOT_CLK
This configuration group manages the clock settings for various buses and the CPU frequency in a system. It allows for the adjustment of clock dividers and PLL parameters to optimize performance and speed up operations, such as updates from SPI flash.
| Macro | Description | Sample value(s) |
|---|---|---|
MBOOT_CLK_AHB_DIV |
Sets the AHB clock divider for the microcontroller. | (RCC_SYSCLK_DIV1) |
MBOOT_CLK_APB1_DIV |
Defines the clock divider for the APB1 bus. | (RCC_HCLK_DIV4) |
MBOOT_CLK_APB2_DIV |
Defines the clock divider for the APB2 bus. | (RCC_HCLK_DIV2) |
MBOOT_CLK_APB3_DIV |
Defines the clock divider for APB3 peripheral bus. | (RCC_APB3_DIV2) |
MBOOT_CLK_APB4_DIV |
Defines the clock divider for the APB4 bus. | (RCC_APB4_DIV2) |
MBOOT_CLK_PLLM |
Calculates the PLLM value for configuring the CPU frequency to 96MHz. | (MICROPY_HW_CLK_VALUE / 1000000) |
MBOOT_CLK_PLLN |
Sets the value for the PLLN parameter in the clock configuration, influencing the CPU frequency. | (192) |
MBOOT_CLK_PLLP |
Calculates the PLLP value based on PLLN and core clock frequency. | (MBOOT_CLK_PLLN / (CORE_PLL_FREQ / 1000000)) |
MBOOT_CLK_PLLQ |
Sets the division factor for the PLL output clock Q. | (4) |
MBOOT_CLK_PLLR |
Sets the divisor for the PLLR clock output. | (2) |
MBOOT_SPIFLASH
This configuration group manages the settings and parameters for accessing and utilizing external QSPI flash memory in the Mboot bootloader. It includes specifications for memory layout, communication pins, and operational characteristics, enabling efficient interaction with the flash storage.
| Macro | Description | Sample value(s) |
|---|---|---|
MBOOT_SPIFLASH_ADDR |
Address for Mboot to access external QSPI flash. | (0x90000000) |
MBOOT_SPIFLASH_BYTE_SIZE |
Calculates the size of the SPI flash memory based on the log2 of its memory size. | (1 << MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0->memory_size_bytes_log2) |
MBOOT_SPIFLASH_CONFIG |
Points to the SPI flash configuration structure for external flash initialization. | (&board_mboot_spiflash_config) |
MBOOT_SPIFLASH_CS |
Defines the chip select pin for the SPI flash memory. | (pyb_pin_XSPIM_P2_CS) |
MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE |
Determines the number of erase blocks per page for SPI flash memory. | (128 / 4) // 128k page, 4k erase block |
MBOOT_SPIFLASH_LAYOUT |
Determines the layout of the SPI flash based on the memory size log2 value. | (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS0->memory_size_bytes_log2 == 21 ? "/0x80000000/5124Kg" : "/0x80000000/20484Kg") |
MBOOT_SPIFLASH_LAYOUT_DYNAMIC_MAX_LEN |
Defines the maximum length for the dynamic layout of Mboot SPI flash #1. | (20) |
MBOOT_SPIFLASH_MISO |
Defines the MISO pin for the SPI flash interface. | (pyb_pin_XSPIM_P2_IO1) |
MBOOT_SPIFLASH_MOSI |
Defines the MOSI pin for SPI flash communication. | (pyb_pin_XSPIM_P2_IO0) |
MBOOT_SPIFLASH_SCK |
Defines the SCK pin for SPI flash communication. | (pyb_pin_XSPIM_P2_SCK) |
MBOOT_SPIFLASH_SPIFLASH |
Pointer to the SPI flash device structure for bootloader operations. | (&board_mboot_spiflash) |
MBOOT_MISC
This collection of macros configures various aspects of the bootloader functionality, including hardware initialization, error handling, and system state management. It allows for customization of boot processes, error messaging, and peripheral settings, ensuring a flexible and robust bootloader environment.
| Macro | Description | Sample value(s) |
|---|---|---|
MBOOT_ADDRESS_SPACE_64BIT |
Enables 64-bit address space for mboot, affecting address type and firmware loading. | (0) |
MBOOT_BOARD_CLEANUP |
Calls the board-specific cleanup function during the bootloader process. | board_mboot_cleanup |
MBOOT_BOARD_GET_RESET_MODE |
Retrieves the reset mode for the board during the bootloader process. | board_mboot_get_reset_mode |
MBOOT_BOARD_LED_INIT |
Calls a custom LED initialization function for the board. | board_mboot_led_init |
MBOOT_BOARD_LED_STATE |
Custom function for controlling the LED state on the board. | board_mboot_led_state |
MBOOT_BOARD_STATE_CHANGE |
Handles state changes for the bootloader, utilizing a default UI if enabled. | board_mboot_state_change |
MBOOT_BOOTPIN_ACTIVE |
Indicates the active state of the boot pin for entering the bootloader. | (0) |
MBOOT_BOOTPIN_PIN |
Configures the pin used to trigger entry into the bootloader. | (pin_A10) |
MBOOT_BOOTPIN_PULL |
Configures the pull-up/pull-down resistor setting for the boot pin. | (MP_HAL_PIN_PULL_NONE) |
MBOOT_ENABLE_DEFAULT_UI |
Enables the default user interface code if at least one LED is configured. | (1) |
MBOOT_ERRNO_VFS_LFS_MOUNT_FAILED |
Error code for failed mounting of LFS1 or LFS2 in the virtual file system. | MBOOT_ERRNO_VFS_LFS1_MOUNT_FAILED |
MBOOT_ERRNO_VFS_LFS_OPEN_FAILED |
Error code indicating failure to open a file in the LFS (LittleFS) virtual filesystem. | MBOOT_ERRNO_VFS_LFS1_OPEN_FAILED |
MBOOT_ERROR_STR_INVALID_ADDRESS |
Error message indicating an address is out of range. | "Address out of range" |
MBOOT_ERROR_STR_INVALID_ADDRESS_IDX |
Index for the error message indicating an invalid address in DFU operations. | 0x11 |
MBOOT_ERROR_STR_INVALID_READ |
Indicates that read operations are not supported on an encrypted bootloader. | "Read support disabled on encrypted bootloader" |
MBOOT_ERROR_STR_INVALID_READ_IDX |
Error code indicating read support is disabled on an encrypted bootloader. | 0x13 |
MBOOT_ERROR_STR_INVALID_SIG |
Error message indicating an invalid signature in a file. | "Invalid signature in file" |
MBOOT_ERROR_STR_INVALID_SIG_IDX |
Error index for an invalid signature in the firmware file. | 0x12 |
MBOOT_ERROR_STR_OVERWRITE_BOOTLOADER |
Error message indicating that the bootloader cannot be overwritten. | "Can't overwrite mboot" |
MBOOT_ERROR_STR_OVERWRITE_BOOTLOADER_IDX |
Index for the error message indicating that overwriting the bootloader is not allowed. | 0x10 |
MBOOT_FLASH_LATENCY |
Configures the flash memory access latency for the bootloader. | FLASH_LATENCY_3 |
MBOOT_FSLOAD |
Enables loading firmware from a filesystem. | (0) |
MBOOT_FSLOAD_DEFAULT_BLOCK_SIZE |
Default block size for mount operations, set to 4096 bytes. | (4096) |
MBOOT_I2C_ALTFUNC |
Defines the alternate function number for I2C pins. | (4) |
MBOOT_I2C_PERIPH_ID |
Identifies the I2C peripheral used for bootloader communication. | 1 |
MBOOT_I2C_SCL |
Defines the I2C SCL pin for the bootloader configuration. | (pin_B10) |
MBOOT_I2C_SDA |
Defines the I2C data line pin for the bootloader. | (pin_B11) |
MBOOT_INITIAL_R0_KEY |
Value used in initial_r0 for programmatic entry into the mboot. | (0x70ad0000) |
MBOOT_INITIAL_R0_KEY_FSLOAD |
Value used to indicate the bootloader should enter filesystem load mode. | (MBOOT_INITIAL_R0_KEY | 0x80) |
MBOOT_LEAVE_BOOTLOADER_VIA_RESET |
Determines whether the bootloader exits via a reset or a direct jump to the application. | (1) |
MBOOT_LED1 |
Defines the identifier for the first LED, used in bootloader UI. | 0 |
MBOOT_LED2 |
Represents the identifier for the second LED in the bootloader. | 1 |
MBOOT_LED3 |
Represents the identifier for the third LED in the bootloader. | 2 |
MBOOT_LED_STATE_LED0 |
Represents the state of LED0 for use in the led_state_all() function, allowing multiple LED states to be combined. | (0x01) |
MBOOT_LED_STATE_LED1 |
Represents the state of LED1 in the bootloader's LED control. | (0x02) |
MBOOT_LED_STATE_LED2 |
Represents the state of LED2 with a value of 0x04. | (0x04) |
MBOOT_LED_STATE_LED3 |
Represents the state of LED3 with a value of 0x08 for LED control. | (0x08) |
MBOOT_PACK_DFU_CHUNK_BUF_SIZE |
Maximum size for the firmware payload buffer, combining chunk size and header bytes. | (MBOOT_PACK_CHUNKSIZE + hydro_secretbox_HEADERBYTES) |
MBOOT_PACK_GZIP_BUFFER_SIZE |
Sets the buffer size for decompressing gzip files during firmware updates. | (2048) |
MBOOT_PACK_HEADER_VERSION |
Indicates the current version of a packed DFU file. | (1) |
MBOOT_PACK_HYDRO_CONTEXT |
Context string for signing and secretbox operations using libhydrogen. | "mbootenc" |
MBOOT_SDCARD_ADDR |
Defines the starting address for SD card memory mapping. | (0x100000000ULL) |
MBOOT_SDCARD_BYTE_SIZE |
Defines the byte size of the SD card memory space. | (0x400000000ULL) |
MBOOT_SPIFLASH2_ADDR |
Address for the second external SPI flash device. | (0x90000000) |
MBOOT_SPIFLASH2_BYTE_SIZE |
Calculates the byte size of the second SPI flash based on its memory size logarithm. | (1 << MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2) |
MBOOT_SPIFLASH2_CONFIG |
Pointer to the configuration structure for the second SPI flash. | (&spiflash2_config) |
MBOOT_SPIFLASH2_ERASE_BLOCKS_PER_PAGE |
Determines the number of erase blocks per page for the second SPI flash. | (32 / 4) |
MBOOT_SPIFLASH2_LAYOUT |
Determines the layout of the second SPI flash based on its memory size. | (MICROPY_BOARD_SPIFLASH_CHIP_PARAMS1->memory_size_bytes_log2 == 21 ? "/0x90000000/5124Kg" : "/0x90000000/20484Kg") |
MBOOT_SPIFLASH2_LAYOUT_DYNAMIC_MAX_LEN |
Defines the maximum length for the dynamic layout of Mboot SPI flash #2. | (20) |
MBOOT_SPIFLASH2_SPIFLASH |
Pointer to the second SPI flash device structure. | (&spi_bdev2.spiflash) |
MBOOT_USBD_LANGID_STRING |
Language ID for USB descriptors, set to 0x409 (English - United States). Examples: 0x409, 0x0409. | (0x409) |
MBOOT_USBD_MANUFACTURER_STRING |
Defines the USB manufacturer string for the bootloader. | "MicroPython" |
MBOOT_USBD_PRODUCT_STRING |
Defines the product string for USB device identification. | "phyBOARD Boot" |
MBOOT_USB_AUTODETECT_PORT |
Enables automatic detection of USB ports during bootloader operation. | (1) |
MBOOT_USB_PID |
Defines the USB Product ID for the bootloader. | BOOTLOADER_DFU_USB_PID |
MBOOT_USB_VID |
Defines the USB Vendor ID for the bootloader. | BOOTLOADER_DFU_USB_VID |
MBOOT_VERSION |
Defines the version string for the mboot, incorporating the MICROPY_GIT_TAG. | "mboot-" MICROPY_GIT_TAG |
MBOOT_VERSION_64BIT |
Defines the bootloader version for 64-bit address space with I2C support. | MBOOT_VERSION_I2C ".64" |
MBOOT_VERSION_FAT |
Defines the version string for FAT file system support, appending '.fat' to the 64-bit version. | MBOOT_VERSION_64BIT ".fat" |
MBOOT_VERSION_FINAL |
Final version string for the bootloader, derived from MBOOT_VERSION_RAW. | MBOOT_VERSION_RAW |
MBOOT_VERSION_I2C |
Combines USB version with '.i2c' if I2C support is enabled. | MBOOT_VERSION_USB ".i2c" |
MBOOT_VERSION_LFS1 |
Combines MBOOT_VERSION_FAT with the suffix '.lfs1' if LFS1 is enabled. | MBOOT_VERSION_FAT ".lfs1" |
MBOOT_VERSION_LFS2 |
Combines MBOOT_VERSION_LFS1 with the suffix '.lfs2' if MBOOT_VFS_LFS2 is enabled. | MBOOT_VERSION_LFS1 ".lfs2" |
MBOOT_VERSION_RAW |
Combines MBOOT_VERSION_LFS2 with the suffix '.raw' if MBOOT_VFS_RAW is enabled. | MBOOT_VERSION_LFS2 ".raw" |
MBOOT_VERSION_USB |
Appends '+usb' to the MBOOT version string, indicating USB support. | MBOOT_VERSION "+usb" // USB is always included |
MBOOT_VFS_FAT |
Enables support for FAT filesystems in the bootloader. | (0) |
MBOOT_VFS_LFS1 |
Enables support for Littlefs v1 filesystems. | (0) |
MBOOT_VFS_LFS2 |
Enables support for Littlefs v2 filesystems. | (0) |
MBOOT_VFS_RAW |
Enables support for raw filesystems in the bootloader. | (MBOOT_FSLOAD) |