What if change the system-part1, system-part2 and user part begin address?


I’v looked into the code and found that the system-part1 locates from address 0x08020000 to 0x0805FFFF, system-part2 locates from address 0x08060000 to 0x0809FFFF and the user-part locates from address 0x080A0000 to 0x080bFFFF. So my question is, if I change the system-part2 to locate from address 0x080A0000 to 0x080DFFFF and change the user-part to locate from address 0x080E0000 to 0x080FFFFF, will the photon still work properly? If not, what else should be changed to make it work?

Best regards

What’s the problem you are trying to solve that requires you to do that?

Basically, the Photon wouldn’t run.

I am trying to port another Broadcom wifi chip 43438 to photon, which result in the system-part1 size rising to 399 KB. So I locate the system-part1 from address 0x08020000 to 0x0809FFFF.
Regardless of whether I success or not, why it doesn’t work if I remap the memory for the firmware architecture? Is there any code snip in the firmware try refering a solid address, instead of using a symbol privided by linker script?

Somewhere here i guess - https://github.com/spark/firmware/blob/latest/modules/photon/system-part1/linker.ld#L6

Yes I have modified not only the script you point out, but also any other makefiles and linker scripts reference to the firmware address. I finally built the system firmware and no error occured.

I’v tested on photon that I didn’t change the firmware for photon, including bootloader, system-part1 and system-part2, and only change the memory map as below:

bootloader: 0x08000000 ~ 0x08003FFF (unchanged)
DCT1: 0x08004000 ~ 0x08007FFF(unchanged)
DCT2: 0x08008000 ~ 0x0800BFFF(unchanged)
EEPROM: 0x0800C000 ~ 08014000(unchanged)

system-part1: 0x08020000 ~ 0x0809FFFF (before:0x08020000 ~ 0x0805FFFF)
system-part2: 0x080A0000 ~ 0x080DFFFF (before:0x08060000 ~ 0x0809FFFF)
user-part: 0x080E0000 ~ 0x080FFFFF (before:0x080A0000 ~ 0x080BFFFF)

After downloading the system-part1 and system-part2 via dfu-util, the Photon reset and the indicator LED show solid white and then blink red with auto-reset periodically.

Can anyone explain how?

You probably have to change more than the linker script. There could be hard coded addresses for the execution points of each section.

I am only guessing.

The files I have modified:

  1. firmware-develop\modules\photon\modular.mk:

  2. firmware-develop\modules\photon\system-part1\linker.ld:
    APP_FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 512K

  3. firmware-develop\modules\photon\system-part2\linker.ld:
    APP_FLASH (rx) : ORIGIN = 0x080A0000, LENGTH = 256K

  4. firmware-develop\modules\photon\system-part2\module_system_part2_export.ld:
    system_part2_start = 0x80A0000;

  5. firmware-develop\modules\photon\system-part2\makefile:
    PLATFORM_DFU = 0x80A0000

  6. firmware-develop\modules\photon\user-part\linker.ld:
    APP_FLASH (rx) : ORIGIN = 0x080E0000, LENGTH = 128K

  7. firmware-develop\modules\photon\user-part\module_user_export.ld:
    user_module_info = 0x80E0000 ;

And I also found that the bootloader jumps to the system-part correctly and call the function void HAL_Core_Config(void) successfully. It crashed before entering the function void application_start()

1 Like

Great questions and I’m not sure of the answer. We had to work very, very hard to fit WICED into the available erase sectors in a sensible way. When some of the firmware team gets back from vacation, they might be able to answer. I do know that we use all of the flash:

  • 802–806: system part 1
  • 806–80A: system part 2
  • 80A–80C: application
  • 80C–80E: OTA backup
  • 80E–810: factory backup


@ielec and I are from RedBearLab, we are working very hard to make our NEW board to work with Particle firmware, please help. Thank you!


I finally make it work after changing the memory map as I want. Besides that changing the files listed above, one more thing to be done is commenting the code from line 233 to line 241 as below in file firmware-develop\hal\src\stm32f2xx\core_hal_stm32f2xx.c :

    //Reset and let bootloader perform the user module factory reset
    //Doing this instead of calling FLASH_RestoreFromFactoryResetModuleSlot()
    //saves precious system_part2 flash size i.e. fits in < 128KB

    while(1);//Device should reset before reaching this line

This because the function FLASH_isUserModuleInfoValid(FLASH_INTERNAL, INTERNAL_FLASH_FAC_ADDRESS, USER_FIRMWARE_IMAGE_LOCATION) will access an invalid flash address.

Although making Photon work after changing the memory map, I still can’t make another Broadcom chip 43438 work. The library resources.a is replaced by copying from WICED SDK 3.3.1. After downloading system-part1 and system-part2, the target reset and the RGB LED worked weirdly. It first worked as solid white for many seconds and then blink white for many seconds, finally it worked as solid green with red pixel fading periodically.

Hi @ielec,

You definitely don’t want to comment out the FLASH_isUserModuleInfoValid check! If you comment it out, you let the firmware continue with a factory reset and copy from one place in flash to another whatever arbitrary garbage is stored regardless of whether it is a well-formed firmware module. No wonder your LED is acting strange! :smile:

The linker defines lots of info about each module that gets prepended and appended to the firmware binary, including module metadata, third-party product version, and a full file CRC check. If you don’t see that data at the beginning and end, you do not have a valid firmware module.

So psyched to hear you’re working on a new board! That Broadcom chip opens up some exciting possibilities! Here are Particle we are neck deep in the Electron right now, across hardware, firmware, cloud, carrier API integrations, cellular data management in the dashboard, protocol optimizations in the device service, and mobile setup process. We don’t have bandwidth to help you port to a new chip, but I and the rest of the community here will of course help out when we know the answers to your questions. You’re diving pretty deep there moving the modules around!


1 Like