memory_regions.icf is not updating with flash_image start_address and few other parameters when generated by IAR EWARM.

Hi,

I am trying to implement MCUBoot with blinky project example using RASC and IAR EWARM on RA6M5. I have built the application1 project but the memory_regions.icf file is missing few parameters like: 

FSP_BOOTABLE_IMAGE = 0x1;
RAM_NS_START = 0x20080000;
FLASH_NS_START = 0x40000;
FLASH_IMAGE_END = 0x40000;
FLASH_NS_IMAGE_START = 0x40000;
FLASH_NSC_START = 0x40000;
RAM_NSC_START = 0x20080000;
FLASH_IMAGE_LENGTH = 0x1FE00;
XIP_SECONDARY_FLASH_IMAGE_END = 0x60000;
XIP_SECONDARY_FLASH_IMAGE_START = 0x40200;
FLASH_IMAGE_START = 0x20200;

But the memory_regions.ld of the same application that i had built before using E2Studio has the following parameters. Why are these parameters missing and if I add them manually in memory_regions.icf and build it they get erased from the .icf file. How do i fix this?

Parents
  • Hello  ,

    Thanks for reaching out Renesas Engineering Community.

    The e2studio includes a tooling mechanism which the application project can use to pick up the bootloader project, the flash layout settings and a python command line for creating finally the signed application image. In IAR this tooling mechanism doesn't exist so you have to do some work manually to make it work.

    Basically as soon as you add in Build settings of your application project in e2studio the .bld file of the bootloader it modifies the memory_regions.ld file automatically to include the information for the flash layout:

    So in IAR as you mentioned you need to modify manually the necessary info for the flash layout in the memory_regions.icf file and modify it according your flash layout:

    In order these settings won't be overwritten every time you build your project in IAR when using newer RASC versions than 5.2.0 there is a batch file which launches RASC and generated code every time you build your project and that's why you loose the modifications you make to the memory_regions.icf file. To prevent this batch file from running and generate code through RASC and loose your changes every time you build the project you should go to your project Options->Build Actions and remove this Pre-Built and Post-Build commands:

    In my case I made tests with a bootloader project for EK-RA6M5 using overwrite only upgrade mode and I created in IAR a bootloader project using MCUboot and a blinky application project. I will also attach here the projects for your reference.

    So as soon as I created my bootloader project in IAR using MCUboot and RASC , generated code and built my bootloader project I proceeded creating my application image blinky project with RASC again.

    1.In my application project I modified the memory_regions.icf file to include the flash layout information by doing the steps mentioned above.

    2. I built my application project.

    3. Than I need to convert the output file generated to a .bin file. To do this I run this command in command line:

    arm-none-eabi-objcopy.exe -O binary Debug\Exe\app_ra6m5_boot.out Debug\Exe\app_ra6m5_boot.out.bin

    4. The binary file now also contains the option setting registers so to remove these from the binary file I cropped the generated binary by using srec_cat.exe. So I run this command:

    srec_cat.exe Debug\Exe\app_ra6m5_boot.out.bin -binary -crop 0 0x1FB00 -o Debug\Exe\app_ra6m5_boot.out.bin.cropped -binary

    And by this way I created a cropped binary finally that doesn't include the option setting registers.

    5.Then I signed this cropped binary file by running this python script from the bootloader project in command line:

    python ..\mcuboot_ra6m5\ra\mcu-tools\MCUboot\scripts\imgtool.py sign --key ..\mcuboot_ra6m5\ra\mcu-tools\MCUboot\root-ec-p256.pem --version 1.0 --header-size 0x200 --align 128 --max-align 128 --slot-size 0x20000 --max-sectors 4 --overwrite-only --confirm --pad-header Debug\Exe\app_ra6m5_boot.out.bin.cropped Debug\Exe\app_ra6m5_boot.out.bin.cropped.signed

    6. Then I needed to write the application image to the area of internal flash that I have declared as primary slot in my bootloader layout.

    So I loaded into the area where the primary slot starts and I verified that this area includes the application image:

    And that the rest areas like from example from where bootloader starts are blank:

    And this it when I launched a debug session in IAR in my bootloader project the bootloader was able to jump to my application image and I could see the leds on EK-RA6M5 blinking.

    Find the projects in this link for your reference. 

    Your files can be downloaded at:
    download.transfer.hennge.com/jK0A_abcIZaqq3

    Expiration date: 2025-04-17 14:24 (UTC)

    Your files can be accessed with the following password:
    6dx1nV1p*8gV

    Best Regards,

    IK

  • Hello  ,

    I saw that you downloaded the projects. Is there any feedback you would like to share?

    Thanks and Regards,

    IK

  • Hi,

    Thanks a lot for the immediate response. 

    I downloaded it yesterday thinking I would implement it. But unfortunately, day before yesterday I dumped the hex file of bootloader to the board and since then I am not able to erase this board or write to it. I can only read it. 

    The bootloader has instruction to write Fs onto address 0x0100a134 but that address is filled with 00. So I got to know that the FSPR Bit is set to 0 and we cannot write it to 1. I dint write 0 to it. I dont know what made it 0.

    Also, when I tried to initialize it with RASC, initialisation failed with error code DA. 

    This is my bootloader.

    :100000005825002045070000990400005107000012
    :100010005107000051070000510700005107000080
    :100020000000000000000000000000005107000078
    :1000300051070000000000005107000051070000B8
    :1000400000000000000000000000000000000000B0
    :1000500000000000000000000000000000000000A0
    :100060000000000000000000000000000000000090
    :100070000000000000000000000000000000000080
    :100080000000000000000000000000000000000070
    :100090000000000000000000000000000000000060
    :1000A0000000000000000000000000000000000050
    :1000B0000000000000000000000000000000000040
    :1000C0000000000000000000000000000000000030
    :1000D0000000000000000000000000000000000020
    :1000E0000000000000000000000000000000000010
    :1000F0000000000000000000000000000000000000
    :100100000100020008001000DFF8BC110120088087
    :1001100008880028FCD10120DFF8B01108800120F8
    :10012000DFF8AC1108600120DFF8A8110860704703
    :100130006A480078C0B26A490968C1F30261664A38
    :1001400052F82000C84067490860704780B5032016
    :100150006549087065486249086005205F49087074
    :10016000FFF7E6FF6248F12101700121614A117039
    :10017000F021017001BD80B557485F4901605F49BA
    :1001800041604FF4004181605D4AC26001615D4998
    :100190004161FFF7CDFF01BD10B55B4C4AF2035042
    :1001A0002080FFF7B1FFFFF7E6FF002057490870F6
    :1001B00009205749087000F024F8002055490870BC
    :1001C00055480178C1F3C001C9B20029F8D043F203
    :1001D0000211524A11800021514A11700178C1F375
    :1001E0004011C9B20029F9D0FFF7B0FF01204D49F5
    :1001F000087001204C4908704FF42540208010BD44
    :10020000704710B5494C2078002804D14848007840
    :1002100010F0030F11D02078002808D101202070A1
    :100220000121C82000F090F820780128FCD100209E
    :100230003F4908700020207003E04FF47A70FFF708
    :10024000DFFF10BD80B500203A4908700121C820A9
    :1002500000F07AF838490020087008780028FCD1AE
    :10026000087850F0020008700878C0F34000C0B26F
    :100270000028F9D131490020087008780028FCD105
    :10028000002112E02E4A0800C0B202EB40000378C1
    :1002900013F07F0303700800C0B212F81000C0B260
    :1002A000C009C0B20028F6D1491C0800C0B203281A
    :1002B000E8D3012000F0B5F80020224908700120A1
    :1002C00000F084F801BD000004C1014000C10140FC
    :1002D0000870004000700040A445002026E0014066
    :1002E00020E00140A04500201CC101402112012056
    :1002F0000C20004008200040002D310100127A003F
    :1003000000366E0100C2EB0BFEE3014013E4014036
    :10031000A2E0014032E001403CE0014028E0014021
    :100320002AE0014030E0014052E0014080E4014019
    :1003300081E4014028300840243008402230084041
    :1003400040300840BBE40140F8B5002248431A4958
    :1003500009681A4AB2FBF1FC4FF47A7400250021B7
    :10036000A4FB002304FB013305FB00330026012717
    :10037000BB4206D801D3B24203D2B2FBFCF08008E4
    :1003800014E05FEA8C01B0FBF1F20023A4FB020150
    :1003900004FB031105FB021100220123994203D83B
    :1003A00001D3904200D201E05FF0FF30002801D07D
    :1003B00000F006F8F1BD0000A045002000CA9A3BFD
    :1003C00001380028FCD170477047000010B40021AC
    :1003D000EFF31082012181F31088244B0100C9B290
    :1003E00033F81110002908D00100C9B233F81110F8
    :1003F000491E0400E4B223F814100100C9B233F816
    :100400001110002909D11A490B8853F42543194CBE
    :10041000C0B234F8100083430B8082F3108810BC04
    :10042000704770B40021EFF31082012181F310882E
    :100430000E4B0100C9B233F8111000290AD10C4C3F
    :1004400025880C490600F6B231F816100D4355F414
    :10045000254525800100C9B233F81110491CC0B2EE
    :1004600023F8101082F3108870BC70479845002064
    :10047000FEE301400001000080B50100134A0800BE
    :10048000C0B252F82000002805D00800C0B2C9B29E
    :1004900052F82110884701BD38B50D4804880D4831
    :1004A0000088044000250AE00121A940200080B214
    :1004B000084203D02800C0B2FFF7DEFF6D1C280001
    :1004C000C0B21028F0DB0448048031BD584500203C
    :1004D0002061004040610040306100403EB5032093
    :1004E000FFF79FFF7FF0FF00224908600C21FF22E9
    :1004F0006C46200000F048F8002014E01E4931F955
    :10050000101089B200290DD00200520910F01F030B
    :10051000694651F82240012515FA03F334EA030332
    :1005200041F82230401C6028E8D3144900220AE038
    :10053000684650F8223041F8223050F82200104B23
    :1005400043F82200521C032AF2D30320FFF73EFF98
    :1005500000200BE0084931F9102092B2002A04D0A3
    :1005600031F91010074A42F82010401C6028F1D3DE
    :1005700037BD00BF48800040400000007080004050
    :1005800080E300E00063004062F30F2262F31F4249
    :10059000401810F0030308D0C91A1FD3DB0748BF67
    :1005A00000F8012D28BF20F8022D130030B41446A6
    :1005B0001546103928BF20E93C00FAD8490728BF62
    :1005C00020E90C0048BF40F8042D890028BF20F81E
    :1005D000022D48BF00F8012D30BC7047C91818BF64
    :1005E00000F8012DCB0728BF00F8012D704700004F
    :1005F000DFF820110120088008880028FCD10120A4
    :10060000DFF8141108800120DFF8101108600120C4
    :10061000DFF80C1108607047DFF80811020052B2D1
    :1006200001EB8202136833F48033136040B251F857
    :100630002000704710B50400200040B2FFF7ECFF27
    :10064000BFF35F8F200040B2012110F01F0011FAAC
    :1006500000F0DFF8D41064B2640941F8240010BD42
    :1006600040B2012210F01F018A40DFF8C01040099B
    :1006700041F82020704710B50400200040B2FFF779
    :10068000D9FF200040B2FFF7EBFF10BD010049B2D7
    :10069000012211F01F0112FA01F1DFF8942040B29B
    :1006A000400942F82010BFF34F8FBFF36F8F7047A0
    :1006B0002148006810F00700072801D11F4800E01A
    :1006C0001F48704738B5050000244FF4964000904D
    :1006D00068680078012809D1686890F91100FFF76F
    :1006E000CAFF686890F91300FFF7C5FF11494AF681
    :1006F0008020088002E00098401E00900888802832
    :1007000005D000980028F6D14FF4FA7000E02000E0
    :1007100032BD000004C1014000C10140087000402A
    :10072000007000400063004080E200E000E100E073
    :1007300080E100E084E07F4090A2000190A10001F0
    :1007400010A2000180B500F005F800F08DF8FEE77A
    :1007500000BE704710B55FF470002E4908602E4C43
    :100760002E480460002000F085F8FFF715FD0120F9
    :1007700000F080F82068B0F5005080F30A8828491E
    :100780000022284C2000FFF7FFFE274A2749284C6B
    :10079000200000F071F8274A2749284C200000F07B
    :1007A0006BF8274A2749284C200000F065F82748B5
    :1007B000274900F09DF8FFF7BBFCFFF743FD03203E
    :1007C000FFF72FFE002005E04FF6FF71214A22F8C7
    :1007D0001010401C0C28F7D30320FFF7F7FD03206F
    :1007E000FFF71FFE00201C49086000201B4908601D
    :1007F00000201B49086000201A4908600320FFF709
    :10080000E5FD022000F036F8FFF768FE002000F05A
    :100810007BF810BD88ED00E00000000008ED00E06E
    :100820004C0000005845002010000000C40E0000DD
    :10083000440500204405000080090000000000205D
    :1008400000000000000000000000000000000000A8
    :1008500000000000100D084004000E4008000E408B
    :100860000C000E4010000E4080B500F002F8002091
    :1008700002BD70477047000062B38B0708D0521E5C
    :1008800011F8013B00F8013B00F024808B07F6D102
    :10089000830740F0208000BF103A07D330B4B1E89E
    :1008A0003810103AA0E83810F9D230BC530724BFF2
    :1008B000B1E80810A0E8081044BF51F8043B40F824
    :1008C000043BD20724BF31F8022B20F8022B44BF8F
    :1008D0000B7803707047083A07D3B1E80810083A5C
    :1008E00040F8043B40F804CBF7D25307E4E700009C
    :1008F00038B504460D46AC4205D020682018804724
    :10090000241DAC42F9D131BD704700004EF688512C
    :10091000CEF20001086840F470000860BFF34F8F0A
    :10092000BFF36F8F4FF00170E1EE100A70470000C7
    :1009300000000805352E382E300000004275696C25
    :100940007420776974682052656E65736173204105
    :100950006476616E63656420466C657869626C6577
    :1009600020536F667477617265205061636B6167B5
    :10097000652076657273696F6E20352E382E3000D3
    :10098000F8B505000E001400002C04D1686890F939
    :10099000110000F07FFA686BDFF8C4140860DFF81C
    :1009A000C414E8200870760802220E70002309E0C3
    :1009B000286B10182863686B10186863A86B401EBA
    :1009C000A8635B1CB34212D2286B00880880286998
    :1009D0000090DFF894040068C0F380200028E7D07E
    :1009E0000098471E00970028F3D1142009E0D0207A
    :1009F0000870002C07D1686890F9110000F04EFAD9
    :100A00000020F2BD641EDFF860040068C0F3C0304F
    :100A10000028F5D1002CF5D11420F2E738B50024D8
    :100A2000DFF848542B78C3F30013DBB2002B0BD054
    :100A3000DFF834341B68C3F38033002B02D02B78EB
    :100A400000232B7040F2F514DFF81C341B680B42B6
    :100A500000D01400002800D00400002C01D000F0C9
    :100A6000F7F8200032BD38B505000020280000F05E
    :100A7000C9F90400002C0CD0200015E0AA688021E0
    :100A80002800FFF77DFF18224FF4A041FFF7C6FFB3
    :100A90000400A86B002801D0002CEFD000F083F8F0
    :100AA000002C00D10400200032BDF8B50400002065
    :100AB00000F0F8F90500DFF8B86329684FF6F87020
    :100AC00070EA010131800E21FF22B71C380000F0CE
    :100AD000EDF9200000F096F932002900200000F026
    :100AE0006AF918220021FFF799FF040000F05BF873
    :100AF000002C00D104002000F2BD10B4036BDFF81D
    :100B000060432360DFF85C3320241C70D0241C7009
    :100B1000036BC9180163816B491E8163002A03D1ED
    :100B2000002010BC7047521EDFF83C030068C0F381
    :100B3000C0300028F4D1002AF5D11420F1E738B5EF
    :100B4000050000202963AA63280000F05BF9040077
    :100B5000002C04D10120DFF81C13088017E02000CE
    :100B600020E02A6A4FF4004108E0286B30F40010BE
    :100B7000B0F5803FF5D2EA694FF400512800FFF745
    :100B8000BCFF19224FF4C041FFF748FF0400A86BD7
    :100B9000002801D0002CE8D000F005F8002C00D18E
    :100BA0000400200032BD38B500240025B24B1A885D
    :100BB0004FF496404FF42A41198004E0002801D1F7
    :100BC0004FF4FA74401E19880029F7D1012A06D182
    :100BD0004DF60110A949088000F06CF907E0802A61
    :100BE00005D1A7490120086008680028FCD140F21F
    :100BF000F510854200D12C00200032BD38B505002B
    :100C000068680078002809D0686890F9110000F041
    :100C100041F9686890F9130000F03CF996480088A3
    :100C200080B2002802D1280000F048F900F010F846
    :100C3000040000F030F8002C00D10400FFF7B3FFEF
    :100C4000002C00D10400002085F83C00200032BDBB
    :100C500081B04FF496400090B3208249087005E0BF
    :100C60000098002811D00098401E00907E4800682F
    :100C7000C0F3C0300028F3D07C480078C0F30010E7
    :100C8000C0B2002803D1002003E0142001E040F2AC
    :100C9000F51001B0704781B04FF49640009050209D
    :100CA0007049087005E00098002811D00098401E97
    :100CB00000906D480068C0F3C0300028F3D06B4846
    :100CC0000078C0F30010C0B2002803D1002003E078
    :100CD000142001E040F2F51001B0704710B4644BED
    :100CE0004FF6FF741C805C8052EAC03252F4F0422E
    :100CF000DA8051F4784199801C815C819C81DC818F
    :100D000010BC7047F8B504000D0016005D48076878
    :100D1000FF0F200000F076F8002817D1760B320084
    :100D20006D0B29003800FFF7D9FF514A56492000C2
    :100D300000F041F818220021FFF770FE0400FFF7D1
    :100D400032FF002C00D104002000F2BDFDE7F8B511
    :100D500006000F001500300000F054F80400002CCD
    :100D600021D1EDB2002D20D11021FF22404C2500D1
    :100D7000280000F09BF8FFB2FF4347F6FF7050EAEF
    :100D8000C730E08022004049300000F014F81822FB
    :100D90000021FFF743FE0400FFF705FF002C00D100
    :100DA00004002000F2BD2000FCE7FFB257F4CC475E
    :100DB00036480780F0E718B48069009008230820BF
    :100DC000274C2160274940240C700B70002303E05E
    :100DD00032F813400C805B1C8342F9D3D02008709A
    :100DE00005E0009800280AD00098401E00901E4898
    :100DF0000068C0F3C0300028F3D0002000E01420C9
    :100E000012BC704738B5050000244FF4964000909E
    :100E100000201F49086068680078012809D16868C7
    :100E200090F9110000F036F8686890F9130000F0AE
    :100E300031F84FF45940114908800F494AF6012012
    :100E4000088002E00098401E00900888012805D024
    :100E500000980028F6D14FF4FA7000E0200032BD6F
    :100E600030E07F4000007E4080E07F4010E07F4027
    :100E700044050020E0E07F4084E07F4044E07F4084
    :100E800004700040DCE07F4030A10001E8E07F40DA
    :100E900000700040DFF800F08D060000DFF800F081
    :100EA00061060000DFF800F0B1060000DFF800F096
    :100EB00089050000DFF800F0F1050000DFF800F020
    :100EC000C5060000FFFF0000000000000000000059
    :040ED000000000001E
    :020000040100F9
    :04A10000FFFFFFFF5F
    :04A11000FFFFFFFF4F
    :04A13400FFFFFFFF2B
    :04A20000FFFDFFFF60
    :04A21000FFFFFFFF4E
    :10A24000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1E
    :10A26000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
    :04A28000F8F8FFFFEC
    :04A29000FFFFFFFFCE
    :10A2C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9E
    :0400000500000745AB
    :00000001FF
    

    Also,

    :04A10000FFFFFFFF5F
    :04A11000FFFFFFFF4F
    :04A13400FFFFFFFF2B
    :04A20000FFFDFFFF60
    :04A21000FFFFFFFF4E
    :10A24000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1E
    :10A26000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
    :04A28000F8F8FFFFEC
    :04A29000FFFFFFFFCE
    :10A2C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9E
    :0400000500000745AB
    :00000001FF

    According to the above instructions, Fs are filled on addresses 0x0100A100 and 0x0100A110 but is filled with 0s from the address 0x0100a134.

    Can you please tell me how to recover my board? I also ran the scripts suggested by this answer but I am unable to recover. Please let me know what I can do. I am unable to find out what caused this issue.

     Could not erase chip RA6M3G 

    Also, on Jflash lite i had dumped the hex file. So my bootloader should have started on address 0x0000000 but when i read the memory with Jmem, I got to know that from 0x00000000 to 0x0002000 the area is filled with 0 and my bootloader is written from address 0x0002000. Will this be the cause of 0 being written on FSPR? Also why did my bootloader start from 0x0002000.

    Please tell me what do i do to fix this.

    Thanks and regards,

    Adithi K

  • Hello  ,

    Looks like your answers were not approved. I have approved them now. Please let me check in more detail this and come back to you.

    Thanks and Regards,

    IK

Reply Children
No Data