Proper setup for debugging Duet3
-
Hi,
sorry for possibly stupid questions but I'm now going to do something which I haven't done before and need help with quite basic things.
I've used to debug my mods for RRF by printing out with debugPrint, but I faced some troubles in which this was not enough. So I'd like to do proper debugging.What I have done by the moment:
- I've got Atmel-Ice, but with custom cable. When I connect Atmel-Ice to Duet, the green light on Atmel at least goes up.
- I tried to connect to Duet3 from Microchip Studio. But the only positive result is reading voltage. Reading the device ID results in:
No device detected. Error 4109 Unable to enter programming mode. Verify device selection, interface settings, target power, security bit, and connections to the target device.
- I tried to connect with openocd from linux, using script from RRF repository, but it resulted in:
Open On-Chip Debugger 0.11.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html DEPRECATED! use 'adapter driver' not 'interface' Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'. Info : flash bank command Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : CMSIS-DAP: SWD Supported Info : CMSIS-DAP: JTAG Supported Info : CMSIS-DAP: FW Version = 1.0 Info : CMSIS-DAP: Serial# = J41800043599 Info : CMSIS-DAP: Interface Initialised (SWD) Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1 Info : CMSIS-DAP: Interface ready Info : clock speed 1800 kHz Error: Error connecting DP: cannot read IDR
Could anybody answer these questions:
- Do I understand right that Atmel-Ice is a suitable hardware for Duet3 at all?
- Is it absolutely necessary to use debug configuration to at least read chip id? My custom configuration was based on release config for Duet3 6HC.
- As I mentioned, the cable is custom though I checked many times and was quite sure about pinout correctness. Can there be any other problems causing the aforementioned error messages, beside possibly wrong pinout/non-debug config?
- Please comment on the topic if you see other problems in my description.
Thanks!
-
@Arplyu It sounds like your Atmel ICE fails to communicate with the SAME70. Are you sure the pin connections are correct? It's been a while since I used the OpenOCD script, but it definitely worked for me with OpenOCD/Eclipse on Linux.
-
@chrishamm Thank you for the reply. I will check the pinout one more time.
-
@Arplyu I have used Atmel Studio + Atmel ICE to debug MB6HC firmware, so this combination does work.
-
@dc42 I went through the same process as Arplyu with the same results.
The target voltage is detected but I'm not able to read the device information (from microchip studio)
Looking at the SWCLK line I do not measure a clock, the line is permanently high.
The SWDIO line toggles between 0 and 3.3 volt every second. Reset seems to work.
I also created my own cable. The ATMEL-ICE is brand new so I assume it is ok.
Any hint is welcome, because I'm out of options. -
@Arplyu
I have exactly the same problems. Did you find a solution in the mean time? -
@LexJames Hi! I solved my particular coding issue without debugger, so I didn't try to get Atmel-ICE working anymore since that. But thank you for getting back to the problem, I still would like to figure out what was wrong with my setup. Just to make it clear: the Atmel-ICE which I have at hands is absolutely functional, it works perfectly when it comes to programming SAMMYC21 devboard, on which I test my modifications to DuetExpansion firmware and DuetBootloader. For debugging Duet3-6HC board I'd like to re-assemble the cable, and here I have a possibly very stupid question, sorry for asking that: how should I map 6HC' SWD_EXT_RESET pin to the Atmel-ICE's pinout? I just realized that in my test it was not connected. I suppose that 6HC's RESET goes to Atmel's nRESET, but what about SWD_EXT_RESET?... Hopefully @dc42 or @chrishamm could also comment regarding the pinout. Thanks!
-
@Arplyu you can ignore the EXT_RESET pin. Our intention was to use that output to feed into the reset input of an expansion board that you needed to install a new bootloader on, using the 6HC to program the expansion board via SWD. However, we found the bootloader protection in the expansion boards sufficiently reliable that we never implemented that facility.
-
@dc42 Sorry to ask you again about debugging the 6HC. I have a newer board v1.02 where SWD_EXT_RST is removed, so that can't be the problem. The fact that I don't see the 2 MHz SWCLK worries me. Is there anything I can verify (either hardware or software) to get a clue what is wrong? Thanks in advance.
-
@LexJames bear in mind that when debugging 6HC firmware on the version 1.02 board, you must use a Debug build because the release builds use the SWDIO and SWDCLK pins to drive LEDs.
-
@dc42 Thanks for this note, that was exactly one of my questions when I started this topic, but unfortunately I didn't specify that I also have hardware revision 1.02. I'll test with debug config next week
-
@dc42 That explains a lot. Thanks!
-
@Arplyu In case you want to verify your ICE, the ATMEL utility 'atprogram' has a nice selftest which allows you to test the wiring. You can run it from the command line.
-
After some struggles, I can finally debug the firmware in Eclipse with ATMEL-ICE. Below some hints for other developers who want to debug the RepRapFirmware on Duet3 6HC.
1 - Make sure to flash a debug version of the firmware before you even try to use ICE.
2 - Install 'OpenOCD' and configure it with 'duet3_openocd.cfg' from the RepRapFirmware repository.
3 - Replace the default debugger 'dbg.exe' with 'arm-none-eabi-gdb.exe'
4 - Make sure that the lock bits of the regions 0 to 40 are cleared. If you do a firmware upgrade those bits
will be set. Use Microchip Studio (+ATMEL-ICE) to clear those bits or flash your image with Microchip
Studio.
5 - Set the compiler optimization flag to -Os. (default is -Og).
Now it should work. -
@LexJames I'm glad you got it working! Thanks for sharing your solution.
-
-
-
Sorry for getting back again to that topic. I finally found time to try compiling the debug version of MB6HC code. However, I'm getting errors if I try to compile for original 3.4.4 (my modified code is based on that, so I'd like to start from exactly this version):
Building target: Duet3Firmware_MB6HC_Debug.elf Invoking: Cross G++ Linker arm-none-eabi-gcc -L"/RRF/CoreN2G/SAME70_CAN_SDHC_USB_RTOS_Debug" -L"/RRF/RRFLibraries/SAME70_RTOS_Debug" -L"/RRF/FreeRTOS/SAME70_Debug" -L"/RRF/CANlib/SAME70_RTOS_Debug" --specs=nosys.specs -Os -Wl,--gc-sections -Wl,--fatal-warnings -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -T"/RRF/RepRapFirmware/src/Hardware/SAME70/same70q20b_flash.ld" -Wl,-Map,"/RRF/RepRapFirmware/Duet3_Debug/Duet3Firmware_MB6HC_Debug.map" -o "Duet3Firmware_MB6HC_Debug.elf" -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group ./src/libcpp/eh_alloc.o ./src/libcpp/vterminate.o ./src/libc/memcmp.o ./src/libc/memcpy.o ./src/libc/memmove.o ./src/libc/memset.o ./src/libc/nano-mallocr.o ./src/libc/strptime.o ./src/bossa/Applet.o ./src/bossa/BossaFlash.o ./src/bossa/Device.o ./src/bossa/EefcFlash.o ./src/bossa/Flasher.o ./src/bossa/Samba.o ./src/bossa/WordCopyApplet.o ./src/bossa/WordCopyArm.o ./src/Tools/Filament.o ./src/Tools/Spindle.o ./src/Tools/Tool.o ./src/Storage/CRC16.o ./src/Storage/CRC32.o ./src/Storage/EmbeddedFiles.o ./src/Storage/FileInfoParser.o ./src/Storage/FileStore.o ./src/Storage/MassStorage.o ./src/SBC/DataTransfer.o ./src/SBC/SbcInterface.o ./src/PrintMonitor/PrintMonitor.o ./src/Platform/Event.o ./src/Platform/Heap.o ./src/Platform/Logger.o ./src/Platform/OutputMemory.o ./src/Platform/Platform.o ./src/Platform/PortControl.o ./src/Platform/RepRap.o ./src/Platform/Roland.o ./src/Platform/Scanner.o ./src/Platform/Tasks.o ./src/Platform/UniqueId.o ./src/ObjectModel/GlobalVariables.o ./src/ObjectModel/ObjectModel.o ./src/ObjectModel/Variable.o ./src/Networking/MulticastDiscovery/MulticastResponder.o ./src/Networking/MulticastDiscovery/fgmc_protocol.o ./src/Networking/LwipEthernet/Lwip/src/netif/bridgeif.o ./src/Networking/LwipEthernet/Lwip/src/netif/bridgeif_fdb.o ./src/Networking/LwipEthernet/Lwip/src/netif/ethernet.o ./src/Networking/LwipEthernet/Lwip/src/netif/lowpan6.o ./src/Networking/LwipEthernet/Lwip/src/netif/lowpan6_ble.o ./src/Networking/LwipEthernet/Lwip/src/netif/lowpan6_common.o ./src/Networking/LwipEthernet/Lwip/src/netif/slipif.o ./src/Networking/LwipEthernet/Lwip/src/netif/zepif.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/dhcp6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/ethip6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/icmp6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/inet6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/ip6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/ip6_addr.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/ip6_frag.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/mld6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv6/nd6.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/autoip.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/dhcp.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/etharp.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/icmp.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/igmp.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/ip4.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/ip4_addr.o ./src/Networking/LwipEthernet/Lwip/src/core/ipv4/ip4_frag.o ./src/Networking/LwipEthernet/Lwip/src/core/altcp.o ./src/Networking/LwipEthernet/Lwip/src/core/altcp_alloc.o ./src/Networking/LwipEthernet/Lwip/src/core/altcp_tcp.o ./src/Networking/LwipEthernet/Lwip/src/core/def.o ./src/Networking/LwipEthernet/Lwip/src/core/dns.o ./src/Networking/LwipEthernet/Lwip/src/core/inet_chksum.o ./src/Networking/LwipEthernet/Lwip/src/core/init.o ./src/Networking/LwipEthernet/Lwip/src/core/ip.o ./src/Networking/LwipEthernet/Lwip/src/core/mem.o ./src/Networking/LwipEthernet/Lwip/src/core/memp.o ./src/Networking/LwipEthernet/Lwip/src/core/netif.o ./src/Networking/LwipEthernet/Lwip/src/core/pbuf.o ./src/Networking/LwipEthernet/Lwip/src/core/raw.o ./src/Networking/LwipEthernet/Lwip/src/core/stats.o ./src/Networking/LwipEthernet/Lwip/src/core/sys.o ./src/Networking/LwipEthernet/Lwip/src/core/tcp.o ./src/Networking/LwipEthernet/Lwip/src/core/tcp_in.o ./src/Networking/LwipEthernet/Lwip/src/core/tcp_out.o ./src/Networking/LwipEthernet/Lwip/src/core/timeouts.o ./src/Networking/LwipEthernet/Lwip/src/core/udp.o ./src/Networking/LwipEthernet/Lwip/src/apps/netbiosns/netbiosns.o ./src/Networking/LwipEthernet/Lwip/src/apps/mdns/mdns.o ./src/Networking/LwipEthernet/Lwip/src/api/api_lib.o ./src/Networking/LwipEthernet/Lwip/src/api/api_msg.o ./src/Networking/LwipEthernet/Lwip/src/api/err.o ./src/Networking/LwipEthernet/Lwip/src/api/if_api.o ./src/Networking/LwipEthernet/Lwip/src/api/netbuf.o ./src/Networking/LwipEthernet/Lwip/src/api/netdb.o ./src/Networking/LwipEthernet/Lwip/src/api/netifapi.o ./src/Networking/LwipEthernet/Lwip/src/api/sockets.o ./src/Networking/LwipEthernet/Lwip/src/api/tcpip.o ./src/Networking/LwipEthernet/GMAC/ethernet_sam.o ./src/Networking/LwipEthernet/LwipEthernetInterface.o ./src/Networking/LwipEthernet/LwipSocket.o ./src/Networking/FtpResponder.o ./src/Networking/HttpResponder.o ./src/Networking/Network.o ./src/Networking/NetworkBuffer.o ./src/Networking/NetworkInterface.o ./src/Networking/NetworkResponder.o ./src/Networking/TelnetResponder.o ./src/Networking/UploadingNetworkResponder.o ./src/Movement/StepperDrivers/DriverMode.o ./src/Movement/StepperDrivers/TMC22xx.o ./src/Movement/StepperDrivers/TMC2660.o ./src/Movement/StepperDrivers/TMC51xx.o ./src/Movement/Kinematics/CoreKinematics.o ./src/Movement/Kinematics/FiveBarScaraKinematics.o ./src/Movement/Kinematics/HangprinterKinematics.o ./src/Movement/Kinematics/Kinematics.o ./src/Movement/Kinematics/LinearDeltaKinematics.o ./src/Movement/Kinematics/PolarKinematics.o ./src/Movement/Kinematics/RotaryDeltaKinematics.o ./src/Movement/Kinematics/RoundBedKinematics.o ./src/Movement/Kinematics/ScaraKinematics.o ./src/Movement/Kinematics/ZLeadscrewKinematics.o ./src/Movement/HeightControl/HeightController.o ./src/Movement/BedProbing/Grid.o ./src/Movement/BedProbing/RandomProbePointSet.o ./src/Movement/AxisShaper.o ./src/Movement/DDA.o ./src/Movement/DDARing.o ./src/Movement/DriveMovement.o ./src/Movement/ExtruderShaper.o ./src/Movement/Move.o ./src/Movement/MoveSegment.o ./src/Movement/RawMove.o ./src/Movement/StepTimer.o ./src/Libraries/sha1/sha1.o ./src/Libraries/sd_mmc/ctrl_access.o ./src/Libraries/sd_mmc/sd_mmc.o ./src/Libraries/sd_mmc/sd_mmc_mem.o ./src/Libraries/sd_mmc/sd_mmc_spi.o ./src/Libraries/Fatfs/diskio.o ./src/Libraries/Fatfs/fattime_rtc.o ./src/Libraries/Fatfs/ff.o ./src/Libraries/Fatfs/ffunicode.o ./src/InputMonitors/InputMonitor.o ./src/Heating/Sensors/AdditionalOutputSensor.o ./src/Heating/Sensors/CpuTemperatureSensor.o ./src/Heating/Sensors/CurrentLoopTemperatureSensor.o ./src/Heating/Sensors/DhtSensor.o ./src/Heating/Sensors/LinearAnalogSensor.o ./src/Heating/Sensors/RemoteSensor.o ./src/Heating/Sensors/RtdSensor31865.o ./src/Heating/Sensors/SensorWithPort.o ./src/Heating/Sensors/SpiTemperatureSensor.o ./src/Heating/Sensors/TemperatureSensor.o ./src/Heating/Sensors/Thermistor.o ./src/Heating/Sensors/ThermocoupleSensor31855.o ./src/Heating/Sensors/ThermocoupleSensor31856.o ./src/Heating/Sensors/TmcDriverTemperatureSensor.o ./src/Heating/FOPDT.o ./src/Heating/Heat.o ./src/Heating/Heater.o ./src/Heating/HeaterMonitor.o ./src/Heating/LocalHeater.o ./src/Heating/RemoteHeater.o ./src/Heating/TemperatureError.o ./src/Hardware/SharedSpi/SharedSpiClient.o ./src/Hardware/SharedSpi/SharedSpiDevice.o ./src/Hardware/SAME70/Ethernet/ksz8081rna/ethernet_phy.o ./src/Hardware/SAME70/Ethernet/GmacInterface.o ./src/Hardware/SAME70/Devices.o ./src/Hardware/SAME70/Main.o ./src/Hardware/ExceptionHandlers.o ./src/Hardware/I2C.o ./src/Hardware/IoPorts.o ./src/Hardware/NonVolatileMemory.o ./src/Hardware/SoftwareReset.o ./src/GPIO/GpInPort.o ./src/GPIO/GpOutPort.o ./src/GCodes/GCodeBuffer/BinaryParser.o ./src/GCodes/GCodeBuffer/ExpressionParser.o ./src/GCodes/GCodeBuffer/GCodeBuffer.o ./src/GCodes/GCodeBuffer/StringParser.o ./src/GCodes/GCodeException.o ./src/GCodes/GCodeFileInfo.o ./src/GCodes/GCodeInput.o ./src/GCodes/GCodeMachineState.o ./src/GCodes/GCodeQueue.o ./src/GCodes/GCodes.o ./src/GCodes/GCodes2.o ./src/GCodes/GCodes3.o ./src/GCodes/GCodes4.o ./src/GCodes/ObjectTracker.o ./src/GCodes/RestorePoint.o ./src/GCodes/StraightProbeSettings.o ./src/GCodes/TriggerItem.o ./src/FilamentMonitors/Duet3DFilamentMonitor.o ./src/FilamentMonitors/FilamentMonitor.o ./src/FilamentMonitors/LaserFilamentMonitor.o ./src/FilamentMonitors/PulsedFilamentMonitor.o ./src/FilamentMonitors/RotatingMagnetFilamentMonitor.o ./src/FilamentMonitors/SimpleFilamentMonitor.o ./src/Fans/Fan.o ./src/Fans/FansManager.o ./src/Fans/LedStripDriver.o ./src/Fans/LocalFan.o ./src/Fans/RemoteFan.o ./src/Endstops/Endstop.o ./src/Endstops/EndstopsManager.o ./src/Endstops/LocalZProbe.o ./src/Endstops/RemoteZProbe.o ./src/Endstops/StallDetectionEndstop.o ./src/Endstops/SwitchEndstop.o ./src/Endstops/ZProbe.o ./src/Endstops/ZProbeEndstop.o ./src/Config/Pins.o ./src/Comms/AuxDevice.o ./src/Comms/FirmwareUpdater.o ./src/Comms/PanelDueUpdater.o ./src/ClosedLoop/ClosedLoop.o ./src/CAN/CanDriversData.o ./src/CAN/CanInterface.o ./src/CAN/CanMessageGenericConstructor.o ./src/CAN/CanMotion.o ./src/CAN/CommandProcessor.o ./src/CAN/ExpansionManager.o ./src/Accelerometers/Accelerometers.o ./src/Accelerometers/LIS3DH.o ./src/RepRapFirmware.o ./src/Version.o -lCoreN2G -lRRFLibraries -lFreeRTOS -lCANlib -lsupc++ -Wl,--end-group -lm /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/SBC/DataTransfer.o: in function `SPI1_Handler': /RRF/RepRapFirmware/Duet3_Debug/../src/SBC/DataTransfer.cpp:366: warning: undefined reference to `SPI1_WiFi_Handler()' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/Networking/Network.o: in function `Network::HandleWiFiCode(int, GCodeBuffer&, StringRef const&, OutputBuffer*&)': /RRF/RepRapFirmware/Duet3_Debug/../src/Networking/Network.cpp:366: warning: undefined reference to `WiFiInterface::HandleWiFiCode(int, GCodeBuffer&, StringRef const&, OutputBuffer*&)' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/Networking/Network.o: in function `Network::ResetWiFiForUpload(bool)': /RRF/RepRapFirmware/Duet3_Debug/../src/Networking/Network.cpp:406: warning: undefined reference to `WiFiInterface::ResetWiFiForUpload(bool)' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/Networking/Network.o: in function `Network::CreateAdditionalInterface()': /RRF/RepRapFirmware/Duet3_Debug/../src/Networking/Network.cpp:205: warning: undefined reference to `WiFiInterface::WiFiInterface(Platform&)' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: /RRF/RepRapFirmware/Duet3_Debug/../src/Networking/Network.cpp:207: warning: undefined reference to `WiFiInterface::Init()' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/Comms/FirmwareUpdater.o: in function `FirmwareUpdater::IsReady()': /RRF/RepRapFirmware/Duet3_Debug/../src/Comms/FirmwareUpdater.cpp:85: warning: undefined reference to `WifiFirmwareUploader::IsReady() const' /opt/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: ./src/Comms/FirmwareUpdater.o: in function `FirmwareUpdater::UpdateModule(unsigned int, unsigned int, StringRef const&)': /RRF/RepRapFirmware/Duet3_Debug/../src/Comms/FirmwareUpdater.cpp:124: warning: undefined reference to `WifiFirmwareUploader::SendUpdateFile(char const*, unsigned long)' collect2: error: ld returned 1 exit status make[1]: *** [makefile:114: Duet3Firmware_MB6HC_Debug.elf] Error 1 make: *** [makefile:99: all] Error 2 "make -j12 all" terminated with exit code 2. Build might be incomplete.
Do you have any ideas what was wrong? Thank you
-
@Arplyu it looks to me that some of the files you are trying to compile are later than those used to build the 3.4.4 release, because we didn't add WiFi support to the 6HC until version 3.4.5.
-
@dc42 thank you for the reply. I use commits with tag "3.4.4" in all projects. Non-debug config from the same commits compiles without any problems, I used that as a start point for my modifications.
PS At the same time, checking out 3.4-dev branches at latest commits in all projects works fine - I managed to compile debug config and test the hardware, everything was ok.