[SOLVED] Change Flash Start Address Code and Startup

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Change Flash Start Address Code and Startup

    Hello,

    I porting a Keil project using the NXP KL17Z128 to SES. I am trying to change the flash start address and sizes as follows:

    Flash Segment 1 (ARM start code)- start 0x0 size 0x400
    Flash Segment 2 (Program Code) - start 0x1000

    I have edited MKL17Z128xxx4_MemoryMap.xml to

    <MemorySegment name="FLASH" start="0x00001000" size="0x00020000" access="ReadOnly" />

    Problem:

    However, inspecting the disassembly and *.bin file, there is still code being placed between 0x410 and 0x1000.

    It seems like Embedded Studio is placing the user code and 0x1000, but it is also perhaps filling in constants and other data or code in the 0x410-0x1000 section. Is there a way to prevent this, perhaps to define a startup section and code section?

    Reason:

    I need to do this because NXP has a security section of flash at 0x400-0x40F that, if erased and not immediately rewritten, can potentially require the whole chip to be erased. If my bootloader failed to erase and write this section, it would wipe out our calibration data and effectively brick the device. My solution was to "jump" the code over this section to avoid having to erase the 0x400 section and risk bricking the device.
  • Hello,

    Thank you for your inquiry.

    lcorbin wrote:

    I need to do this because NXP has a security section of flash at 0x400-0x40F that, if erased and not immediately rewritten, can potentially require the whole chip to be erased.
    We are aware of that. That is why we have two device configurations for each Kinetis device (see attachment).
    If you select the non "allow security device" J-Link will warn you if you are trying to lock the device with your application and edit the binary accordingly.
    To make sure Embedded Studio links the code correctly we suggest using the Kinetis-L series CPU Support package: segger.com/products/developmen…o/technology/cpu-support/
    You can download it under Tools->Package Manager.
    In the Package will be a MKL17Z4_Vectors.s which takes care of the 0x400-0x40F area so you can use all the Flash area around it without any issues.

    Best regards,
    Nino
    Images
    • Capture.PNG

      22.17 kB, 720×480, viewed 55 times
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support contact us per e-mail.
    Alternatively our support system can be used as well: segger.com/ticket/
  • Nino,

    Thanks for the reply. However, I still need to be able to modify where the code is placed due my bootloader configuration.

    I have to be able to re-flash in the field via the on board ROM bootloader chip from a wireless device. As you know, wireless communication and battery powered devices can be very un-reliable so it is not safe for me to have to erase this section of flash. If the bootloader erase is successful but a subsequent write to 0x400 is not, then the device will require a full flash erase. A full flash erase is catastrophic for our system as this would clear out calibration data.
  • Here is what I tried. It sure *seems* to work, but I would like to know if there are any pitfalls to this solutions.

    I added a FLASH_INIT section in the memory map

    XML Source Code

    1. <!DOCTYPE Board_Memory_Definition_File>
    2. <root name="MKL17Z128xxx4">
    3. <MemorySegment name="FLASH" start="0x00001000" size="0x00020000" access="ReadOnly" />
    4. <MemorySegment name="FLASH_INIT" start="0x0000" size="0x0001000" access="ReadOnly" />
    5. <MemorySegment name="RAM" start="0x1FFFE000" size="0x00008000" access="Read/Write" />
    6. </root>
    Display All


    Then I added the .vectors to this section in the flash_placement:


    Smarty-Template

    1. <MemorySegment name="$(FLASH_INIT_NAME:FLASH_INIT)">
    2. <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
    3. </MemorySegment>
    It seems to format the binary file correctly. Please let me know if I need to add anything else to this init section for it to work properly.
  • Hello,

    On first glance this looks correct.
    More information about memory map and section placement file formats can be found in the Embedded Studio help or in our online manual:
    studio.segger.com/ide_memory_map_file_format.htm
    studio.segger.com/ide_section_placement_file_format.htm


    Best regards,

    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support contact us per e-mail.
    Alternatively our support system can be used as well: segger.com/ticket/