[SOLVED] J-Link flashing hifive1-revb target doesn't actually write the correct bytes in the correct location

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

  • [SOLVED] J-Link flashing hifive1-revb target doesn't actually write the correct bytes in the correct location

    using the latest freedom sdk from sifive

    FLASHING (this looks like my test0.hex (which has the correct bytes) was properly flashed to 0x20000000)

    nlivic@null:~/rv2/freedom-e-sdk$ make upload
    scripts/upload --hex /home/nlivic/rv2/freedom-e-sdk/software/test0/debug/test0.hex --jlink JLinkExe
    SEGGER J-Link Commander V6.70 (Compiled Mar 27 2020 14:37:00)
    DLL version V6.70, compiled Mar 27 2020 14:36:47


    Connecting to J-Link via USB...O.K.
    Firmware: J-Link V11 compiled Mar 19 2020 11:11:08
    Hardware version: V11.00
    S/N: 601001907
    License(s): RDI, FlashBP, FlashDL, JFlash, GDB
    VTref=3.309V
    Device "FE310" selected.

    Connecting to target via JTAG
    ConfigTargetSettings() start
    ConfigTargetSettings() end
    TotalIRLen = 5, IRPrint = 0x01
    JTAG chain detection found 1 devices:
    #0 Id: 0x20000913, IRLen: 05, Unknown device
    Debug architecture:
    RISC-V debug: 0.13
    AddrBits: 7
    DataBits: 32
    IdleClks: 5
    Memory access:
    Via system bus: No
    Via ProgBuf: Yes (16 ProgBuf entries)
    DataBuf: 1 entries
    autoexec[0] implemented: Yes
    Detected: RV32 core
    CSR access via abs. commands: No
    Temp. halted CPU for NumHWBP detection
    HW instruction/data BPs: 8
    Support set/clr BPs while running: No
    HW data BPs trigger before execution of inst
    RISC-V identified.
    J-Link>Downloading file [/home/nlivic/rv2/freedom-e-sdk/software/test0/debug/test0.hex]...
    Comparing flash [100%] Done.
    Erasing flash [100%] Done.
    Programming flash [100%] Done.
    Verifying flash [100%] Done.
    J-Link: Flash download: Bank 0 @ 0x20000000: 1 range affected (65536 bytes)
    J-Link: Flash download: Total time needed: 2.873s (Prepare: 0.067s, Compare: 0.768s, Erase: 0.157s, Program: 1.101s, Verify: 0.769s, Restore: 0.009s)
    O.K.
    J-Link>ConfigTargetSettings() start
    ConfigTargetSettings() end
    TotalIRLen = 5, IRPrint = 0x01
    JTAG chain detection found 1 devices:
    #0 Id: 0x20000913, IRLen: 05, Unknown device
    Debug architecture:
    RISC-V debug: 0.13
    AddrBits: 7
    DataBits: 32
    IdleClks: 5
    Memory access:
    Via system bus: No
    Via ProgBuf: Yes (16 ProgBuf entries)
    DataBuf: 1 entries
    autoexec[0] implemented: Yes
    Detected: RV32 core
    CSR access via abs. commands: No
    HW instruction/data BPs: 8
    Support set/clr BPs while running: No
    HW data BPs trigger before execution of inst
    RISC-V: Performing reset via <ndmreset>


    test0.hex

    :020000042001D9
    :100000009711FF5F938181289702000093828205F8
    :100010007390523093020000638402007350107C8E
    :100020001701FFDF130101FE9700FFDF938080FDC2
    :10003000638300008290732540F181450146812051
    :100040009700FFDF938000FC63830000829097029B
    [truncated]

    GDB

    (gdb) monitor long 0x20000004
    Reading from address 0x20000004 (Data = 0x0B018193)
    (gdb) monitor long 0x20000008
    Reading from address 0x20000008 (Data = 0x00004297)
    (gdb) monitor long 0x2000000c
    Reading from address 0x2000000C (Data = 0x60428293)
    (gdb) monitor long 0x2000000b
    Reading from address 0x2000000B (Data = 0x42829300)
    (gdb) monitor long 0x2000000c
    Reading from address 0x2000000C (Data = 0x60428293)
    (gdb) monitor long 0x20000010
    Reading from address 0x20000010 (Data = 0x30529073)
    (gdb) monitor long 0x20000014
    Reading from address 0x20000014 (Data = 0x00000293)
    (gdb) monitor long 0x20000018
    Reading from address 0x20000018 (Data = 0x00028463)
    (gdb) monitor long 0x2000001c
    Reading from address 0x2000001C (Data = 0x7C105073)
    (gdb) monitor long 0x20000020
    Reading from address 0x20000020 (Data = 0xE0000117)
    (gdb) monitor long 0x20000024
    Reading from address 0x20000024 (Data = 0xFE010113)
    (gdb) monitor long 0x20000028
    Reading from address 0x20000028 (Data = 0xE0000097)
    (gdb) monitor long 0x2000002c
    Reading from address 0x2000002C (Data = 0xFD808093)
    (gdb) monitor long 0x20000030
    Reading from address 0x20000030 (Data = 0x00008363)
    (gdb) monitor long 0x20000034
    Reading from address 0x20000034 (Data = 0x25739082)

    Question
    So at address 0x20000004 we should have the value: 93818128 (0x28818193) BUT actually have 0x0B018193. So even though J-Link outputs J-Link: Flash download: Bank 0 @ 0x20000000: 1 range affected (65536 bytes), any idea why, starting at 0x20000000, these locations are not actually overwritten with new code? thanks!!

  • Hi,
    Thank you for your inquiry.
    Such an issue is not known to us.

    nlivic wrote:

    test0.hex

    :020000042001D9
    Address 0x20000004 is not covered by the .hex-file excerpt you provided to us. It is covering 0x2001xxxx.
    To be more specific: 0x20010000, 0x20010010, 0x20010020, 0x20010030, 0x20010040.
    Looking at your hex file, this means 0x28818193 should be found at 0x2001004.

    What I do not understand from the information you provided us with is:
    Why does J-Link Commander say it is writing to 0x20000000?
    Therefore:
    1) Could you please provide us with the whole hex file? You can attach it as file to your reply.
    2) Could you please provide us with the command file / script you used to issue the commands inside the J-Link Commander?
    3) Could you please send us a J-Link log file? How to enable:
    wiki.segger.com/J-Link_DLL#Enable_J-Link_Log_File

    Best regards,
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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 you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Fabian,

    thank you very much for the help. and yes you are right, i see that my program is being flashed starting at 0x20010000. i got this hifive1-revb board second hand, and i was assuming that by default running "make upload" would flash at the beginning of the QSPI region (0x20000000), since it is not; and the code that already lives at 0x20000000 doesn't actually transfer execution to 0x20010000; i effectively cannot get my code to run. i will try and figure this out with freedom studio. with my lack of knowledge, i incorrectly read this line in jlink output- Flash download: Bank 0 @ 0x20000000 as meaning that we flashed starting at that address. i see from the log this is wrong:

    T92966740 000:262.425 JLINK_WriteMem(0x20010000, 0x018E Bytes, ...)
    T92966740 000:262.429 Data: 97 11 FF 5F 93 81 81 28 97 02 00 00 93 82 82 05 ...
    T92966740 000:262.918 completely In flash

    i have also included the upload script. if there are any recommendations of how to get the hex file to be flashed to 0x20000000 instead of 0x20010000 i would be very much appreciative. But i understand this is outside SEGGER and jlink. So thank you very much fabian, you have helped me significantly.

    best,
    nik
    Files
    • rv.log

      (11.18 kB, downloaded 213 times, last: )
    • Makefile.txt

      (10.55 kB, downloaded 189 times, last: )
    • test0.hex

      (68.75 kB, downloaded 192 times, last: )
    • upload.txt

      (1.08 kB, downloaded 197 times, last: )
  • Hi nik,
    You are welcome!

    There are mainly two options here:
    The hacky one and the recommended one.

    Hacky one: You could change the placement by editing the .hex file (Placement and location checksum).
    Please find an edited .hex file attached. Please note, that I did not check if it behaves as intended and that it comes without support claims.

    Recommended one:
    You could create the .hex with the correct location information. This would be the job of the Linker.

    I would recommend to you to try out SEGGER Embedded Studio:
    segger.com/products/development-tools/embedded-studio/

    It is free for evaluation purposes and comes with sample projects for multiple devices, e.g. the HiFive1 Rev B board.
    It makes direct use of the J-Link Hardware without any detours.

    Please find an Embedded Studio blinky sample project for the HiFive1 rev B board here:
    download.segger.com/Fabian/SiFive_HiFive1RevB_Sample.zip
    I created it with the Embedded Studio packet manager.

    As a side note:
    I can see that the J-Link you registered with in this forum is still in support period.
    Therefore you could also make use of our support ticket system, which comes with a faster response time and other advantages.
    For more information please refer to my signature.

    Best regards,
    Fabian
    Files
    • test0.hex

      (68.75 kB, downloaded 174 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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 you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • This is great fabian!! i am running into issues that are definitely outside of the JLink programmer or the rv target. i have two additional hardware components (rv UFO target, and CW308) plus additional layers of software. See pic for my setup. so i did try your blinky example with emStudio and using the JLink debugger and manually placing the PC from 0x2000000 to 0x20010000 so that blinky, would execute but i didn't get the LED on the CW308 to light up. Since JLink is working great, we can close this up (chalk it up to user error). And i can update you later when i get this figured. and good to know that i can use the ticketing system.

    thanks very much fabian!!

    will let you know how it goes. :)

    best.
    nik
    Images
    • 20200408_230633.jpg

      1.54 MB, 1,960×4,032, viewed 187 times
  • Hi Nik,
    Good to hear that you are up and running again.

    We will consider this thread as closed now.

    Best regards,
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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 you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.