• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Duet 3 Flash custom firmware via swd

Scheduled Pinned Locked Moved
Firmware developers
3
6
378
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ?
    A Former User
    last edited by 29 Jul 2022, 21:36

    Hi,

    I was trying to create some custom firmware for the Duet 3 6HC board. The reason for this is, that the hardware supports all the necessary functionality but I don't need the WebServer etc. for my particular application. When I bought the Duet 3 I saw in the hardware docs, that there is a SWD connector. So I thought that I would be able to just open an openocd connection, compile my firmware, flash it on the chip via SWD and use a arm-none-eabi-gdb for debugging. Boy was I wrong 😆

    I am using the following:

    • Duet 3 6HC v1.01
    • STLink V2 and a STLink V2.1 turned into a Jlink, I have tried everything with both
    • Openocd v0.11.0
    • arm-none-eabi-gcc 10.2.1

    Using the following command

    openocd -f interface/jlink.cfg -c "transport select swd" -f target/atsamv.cfg

    I am able to establish an openocd connection to the ATSAME70Q20B processor. I have build some dummy firmware using a Makefile Project created using ATMEL START for the corresponding processor. I was able to compile an elf file, connect my gdb to the openocd socket and flash that firmware. However as soon as I try to create a breakpoint in the main function to step through the programm, it gets stuck in the following backtrace loop and never reaches main:

    #0 0x00800dbe in ?? ()
    #1 0x20400100 in _sheap ()

    I tried erasing over the jumper and reflashing the firmware. Didn't help. I then tried to restore the Reprapfirmware v3.3. I successfully build it using the tutorial, and tried to flash it over swd and got the following error:

    (gdb) load
    Loading section .text, size 0x8947c lma 0x400000
    Loading section .ARM.extab, size 0x14f4 lma 0x48947c
    Loading section .ARM.exidx, size 0x18f0 lma 0x48a970
    Loading section .relocate, size 0x638 lma 0x48c260
    Error finishing flash operation

    openocd output:

    Info : erasing lock regions 0-35...
    Info : erasing lock region 0
    Info : erasing lock region 1
    Info : erasing lock region 2
    Info : erasing lock region 3
    Info : erasing lock region 4
    Info : erasing lock region 5
    Info : erasing lock region 6
    Info : erasing lock region 7
    Info : erasing lock region 8
    Info : erasing lock region 9
    Info : erasing lock region 10
    Info : erasing lock region 11
    Info : erasing lock region 12
    Info : erasing lock region 13
    Info : erasing lock region 14
    Info : erasing lock region 15
    Info : erasing lock region 16
    Info : erasing lock region 17
    Info : erasing lock region 18
    Info : erasing lock region 19
    Info : erasing lock region 20
    Info : erasing lock region 21
    Info : erasing lock region 22
    Info : erasing lock region 23
    Info : erasing lock region 24
    Info : erasing lock region 25
    Info : erasing lock region 26
    Info : erasing lock region 27
    Info : erasing lock region 28
    Info : erasing lock region 29
    Info : erasing lock region 30
    Info : erasing lock region 31
    Info : erasing lock region 32
    Info : erasing lock region 33
    Info : erasing lock region 34
    Info : erasing lock region 35
    Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (2156 ms). Workaround: increase "set remotetimeout" in GDB
    Info : SWD DPIDR 0x0bd11477
    Error: Failed to write memory and, additionally, failed to find out where
    Error: failed to buffer page at 0x00400000
    Error: error writing to flash at address 0x00400000 at offset 0x00000000
    Info : SWD DPIDR 0x0bd11477
    Polling target samv.cpu failed, trying to reexamine
    Info : SWD DPIDR 0x0bd11477
    Info : SWD DPIDR 0x0bd11477
    Error: Could not find MEM-AP to control the core
    Examination failed, GDB will be halted. Polling again in 100ms
    Info : SWD DPIDR 0x0bd11477
    Info : SWD DPIDR 0x0bd11477
    Error: Could not find MEM-AP to control the core
    Info : SWD DPIDR 0x0bd11477
    Info : SWD DPIDR 0x0bd11477
    Info : SWD DPIDR 0x0bd11477
    Info : SWD DPIDR 0x0bd11477
    Info : AP write error, reset will not halt
    Error: DP initialisation failed
    Error executing event gdb-flash-write-end on target samv.cpu:

    What am I missing? Can someone provide me with a tutorial on how to flash the Duet 3 Mainboard via SWD?

    Any help is greatly appreciated. Best regards

    undefined 1 Reply Last reply 29 Jul 2022, 21:47 Reply Quote 0
    • undefined
      alankilian @A Former User
      last edited by 29 Jul 2022, 21:47

      @andgl

      I really don't know much how to help, but do these files in THIS GUTHUB LOCATION help?

      They talk about openocd and SWD.

      or maybe the linker script in THIS LOCATION?

      SeemeCNC Rostock Max V3 converted to V3.2 with a Duet2 Ethernet Firmware 3.2 and SE300

      ? 1 Reply Last reply 29 Jul 2022, 22:10 Reply Quote 0
      • ?
        A Former User @alankilian
        last edited by 29 Jul 2022, 22:10

        @alankilian Thank you for your response. Sadly the openocd script in github is for another in-cirtcuit debugger device, namely a cmsis-dap. I am using a stlink however and my openocd command basically contains the whole contents of the script, but as cmd line parameters. As far as I can tell there should not be an issue using the stlink over the cmsis-dap (at least in theory)

        undefined 1 Reply Last reply 30 Jul 2022, 06:17 Reply Quote 0
        • undefined
          dc42 administrators @A Former User
          last edited by 30 Jul 2022, 06:17

          @andgl I have no problem flashing firmware or debugging over SWD using a Atmel ICE. I originally tried using a Black Magic SWD probe instead, but it turned out that the firmware didn't support the Atmel/Microchip ATSAM MCUs.

          Duet WiFi hardware designer and firmware engineer
          Please do not ask me for Duet support via PM or email, use the forum
          http://www.escher3d.com, https://miscsolutions.wordpress.com

          ? 1 Reply Last reply 1 Aug 2022, 15:12 Reply Quote 0
          • ?
            A Former User @dc42
            last edited by 1 Aug 2022, 15:12

            @dc42 If it's not too much to ask, could you please try flashing a custom Atmel Start project with your setup? Just to make sure, that the issue is not due to some wrong linkerfile settings. Atmel Start can generate you a makefile project with a dummy main function for the ATSAME70Q20B without having to register or anything.

            undefined 1 Reply Last reply 1 Aug 2022, 20:20 Reply Quote 0
            • undefined
              dc42 administrators @A Former User
              last edited by 1 Aug 2022, 20:20

              @andgl if you are using Atmel Start then be aware that it is very buggy, based on my experience with using Atmel Start with the SAME5x processors. Microchip doesn't support it and hasn't fixed showstopper bugs that I reported more than three years ago. I don't have time to set up a SAME70 Atmel Start project and work through the likely bugs.

              Are you sure that your stlink hardware and openocd firmware will work with the SAME70? Have you tried loading and debugging the same Atmel Start project using a Atmel ICE?

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 0
              1 out of 6
              • First post
                1/6
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA