Flashloader r_fl_mot_converter.py question

I am attempting to generate a BCH file from an SREC File for an S7G2-SK image for use with the boot loader code from s7_sk_ux_mass_host_boot_nano_1_2_0_wip.zip.

My command line is "python r_fl_mot_converter.py -i cell_A.srec -o cell_A.bch -m 1024 -f 256 -e 0x0040000 -l 0x0040800 -s 0x3c0000" for a small application that uses only the PMOD cell modem connected to the PMODA connector with code derived from the FWS example.

When I run the command, I get:

Traceback (most recent call last):

  File "r_fl_mot_converter.py", line 803, in <module>

    fl_m.Process()

  File "r_fl_mot_converter.py", line 320, in Process

    self.CRCTable.ProcessRecord(line)

  File "r_fl_mot_converter.py", line 584, in ProcessRecord

    self.ApplyData(address, data)

  File "r_fl_mot_converter.py", line 592, in ApplyData

    self.raw_data[address-self.slotAddress]=val

IndexError: list assignment index out of range

I did some debugging and this appears to be caused by entries at the end of the .srec file for the S7 internal RAM (obviously outside the length specified with the -s option):

S315000585D00000000000000000000000000000000090
S315000585E00000000000000000000000000000000080
S3151FFE000000000000000000000000000000000000CD
S3151FFE001000000000000000000000000000000000BD
S3151FFE002000000000000000000000000000000000AD
S3151FFE0030000000000000000000000000000000009D
S3151FFE0040000000000000000000000000000000008D
S3151FFE0050000000000000000000000000000000007D
S3151FFE0060000000000000000000000000000000006D
S3151FFE0070000000000000000000000000000000005D
S3151FFE0080000000000000000000000000000000004D
S3151FFE0090000000000000000000000000000000003D
S3151FFE00A0000000000000000000000000000000002D
S3151FFE00B0000000000000000000000000000000001D
S3151FFE00C0000000000000000000000000000000000D
S3151FFE00D000000000000000000000000000000000FD
S3151FFE00E000000000000000000000000000000000ED
S3151FFE00F000000000000000000000000000000000DD
S3151FFE010000000000000000000000000000000000CC
S3151FFE011000000000000000000000000000000000BC
S3151FFE012000000000000000000000000000000000AC
S3151FFE0130000000000000000000000000000000009C
S3151FFE0140000000000000000000000000000000008C
S3151FFE0150000000000000000000000000000000007C
S3151FFE0160000000000000000000000000000000006C
S3151FFE0170000000000000000000000000000000005C
S3151FFE0180000000000000000000000000000000004C
S3151FFE0190000000000000000000000000000000003C
S3151FFE01A0000000000000000000000000000000002C
S3151FFE01B0000000000000000000000000000000001C
S70500047CA1D9

How do I handle this?

I tried deleting the entries from the .srec file since they are just initializing the space to 0x00 and then I get:

Traceback (most recent call last):

  File "r_fl_mot_converter.py", line 803, in <module>

    fl_m.Process()

  File "r_fl_mot_converter.py", line 401, in Process

    self.write_block(out_file, cur_buffer, start_address)

  File "r_fl_mot_converter.py", line 200, in write_block

    block_data_crc.update(binascii.unhexlify(current_buffer))

TypeError: Odd-length string

thanks,

pete

  • Are you deleting all the entries that you have shown? I would only delete the 1FFEXX entries since these are just zeroing the first areas in RAM. The first entries shown in your post appear to be flash region and not including them could affect the CRC.
  • In reply to Jacob Beningo:

    Jacob,

    I only deleted the 1FFEXX lines and left the final S70500047CA1D9 line in. I did try removing the lines on two different versions of the SREC file. Once before I modified the linker file to support the boot loader and once after and both seemed to fail at the same point when I modified the python script to print out the BCH block that was being generated.

    I can send the linker and original .srec file if that would be useful.

    thanks,
    pete
  • In reply to Jacob Beningo:

    Jacob,

    I did a little more experimenting and found that the editor I used (vi) changed the EOL characters. I fixed that and it solved the last issue. Now I get:

    Error - Valid mask in Application Header did not match the value it was supposed to be.
    Expected Value = 0xaf Actual Value = 0x10
    Traceback (most recent call last):
    File "r_fl_mot_converter.py", line 803, in <module>
    fl_m.Process()
    File "r_fl_mot_converter.py", line 457, in Process
    self.ProcessHeader(out_file)
    File "r_fl_mot_converter.py", line 502, in ProcessHeader
    raise Exception('Expected Value = ' + hex(self.input_valid_mask) + " Actual Value = " + hex(my_header.valid_mask))
    Exception: Expected Value = 0xaf Actual Value = 0x10

    thanks,
    pete
  • In reply to Jacob Beningo:

    Jacob,

    I believe my latest issue is that the SREC file does not contain the required FLASHLOADER header at 0x00040800. My cell_A project does not have the downloader framework included at all since my plan is to download the file to the QSPI FLASH through the HTTP server and the boot loader will copy from QSPI FLASH to the CODE FLASH and then reset and run it. What is the minimum framework stack required from the FLASHLOADER framework in the application project to insert the header into the SREC file?

    thanks,
    pete
  • In reply to Peter Giacomini:

    Hello Pete,

    The minimum required to provide firmware image header is instance of Firmware Image Internal Framework on sf_firmware_image_internal. Address/pointer to Firmware Image records should be set to 0x800 and Image Identifier should be non-zero. This unfortunately requires instances of r_crc, sf_memory_mcu_flash and r_flash_hp/lp to be included also. If this overhead is unacceptable, you can emulate the framework output by creating a custom array:

    const struct
    {
        uint8_t  valid_mask;
        uint8_t  version_number;

        uint16_t image_identifier;
        uint32_t unused[12];
    } image_file_header BSP_PLACE_IN_SECTION(".sf_firmware_image_file_header") =
    {
        (uint8_t) 0xAFu, <version>, <image_id>, {0}
    }

    Where <version> and <image_id> should be replaced by the values I recommended earlier. You should also verify that the linker script places .sf_firmware_image_file_header at 0x800:

    . = __ROM_Start + 0x800;
    KEEP(*(.sf_firmware_image_file_header*))

    before

    *(.text*)

    Regards

  • In reply to Peter Giacomini:

    Hi Pete,

    Any updates? Were you able to solve all the issues?

    JB
    RenesasRulz Forum Moderator