From 11567dc2e35cb556a32f40496124952b7a3fa824 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Mon, 28 Dec 2020 22:48:41 +0100 Subject: [PATCH 01/22] Added option for running with uncompressed .data section. Thanks @doegox --- armsrc/Makefile | 4 ++++ armsrc/appmain.c | 11 ++++++++++- armsrc/start.c | 20 +++++++++++++++++--- common_arm/Makefile.hal | 3 +++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 46ba4f027..074380058 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -217,8 +217,12 @@ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z $(Q)$(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=compressed_data $^ $@ $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o +ifneq ($(SKIP_COMPRESSION),1) $(info [=] LD $@) $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ +else + $(Q)$(CP) $(OBJDIR)/fullimage.stage1.elf $@ +endif tarbin: $(OBJS) $(info TAR $@) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index fe8566363..b4c3d6a30 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -257,6 +257,9 @@ void ReadMem(int addr) { /* osimage version information is linked in, cf commonutil.h */ /* bootrom version information is pointed to from _bootphase1_version_pointer */ extern char *_bootphase1_version_pointer, _flash_start, _flash_end, __data_src_start__; +#ifdef WITH_NO_COMPRESSION +extern char *_bootrom_end, _bootrom_start, __os_size__; +#endif static void SendVersion(void) { char temp[PM3_CMD_DATA_SIZE - 12]; /* Limited data payload in USB packets */ char VersionString[PM3_CMD_DATA_SIZE - 12] = { '\0' }; @@ -295,9 +298,11 @@ static void SendVersion(void) { strncat(VersionString, "\n ", sizeof(VersionString) - strlen(VersionString) - 1); } } +#ifndef WITH_NO_COMPRESSION // Send Chip ID and used flash memory uint32_t text_and_rodata_section_size = (uint32_t)&__data_src_start__ - (uint32_t)&_flash_start; uint32_t compressed_data_section_size = common_area.arg1; +#endif struct p { uint32_t id; @@ -308,7 +313,11 @@ static void SendVersion(void) { struct p payload; payload.id = *(AT91C_DBGU_CIDR); - payload.section_size = text_and_rodata_section_size + compressed_data_section_size; +#ifdef WITH_NO_COMPRESSION + payload.section_size = (uint32_t)&_bootrom_end - (uint32_t)&_bootrom_start + (uint32_t)&__os_size__; +#else + payload.section_size = text_and_rodata_section_size + compressed_data_section_size; +#endif payload.versionstr_len = strlen(VersionString) + 1; memcpy(payload.versionstr, VersionString, payload.versionstr_len); diff --git a/armsrc/start.c b/armsrc/start.c index 70eee5063..542b9f3f4 100644 --- a/armsrc/start.c +++ b/armsrc/start.c @@ -14,14 +14,16 @@ #include "proxmark3_arm.h" #include "appmain.h" +#ifndef WITH_NO_COMPRESSION #include "lz4.h" +#endif #include "BigBuf.h" #include "string.h" extern struct common_area common_area; extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__; - +#ifndef WITH_NO_COMPRESSION static void uncompress_data_section(void) { int avail_in; memcpy(&avail_in, &__data_src_start__, sizeof(int)); @@ -35,6 +37,7 @@ static void uncompress_data_section(void) { // save the size of the compressed data section common_area.arg1 = avail_in; } +#endif void __attribute__((section(".startos"))) Vector(void); void Vector(void) { @@ -47,12 +50,23 @@ void Vector(void) { common_area.version = 1; } common_area.flags.osimage_present = 1; - - uncompress_data_section(); + +#ifdef WITH_NO_COMPRESSION + /* Set up data segment: Copy from flash to ram */ + char *src = &__data_src_start__; + char *dst = &__data_start__; + char *end = &__data_end__; + while(dst < end) *dst++ = *src++; + dst = &__bss_start__; + end = &__bss_end__; +#else + uncompress_data_section(); /* Set up (that is: clear) BSS. */ char *dst = &__bss_start__; char *end = &__bss_end__; +#endif + while (dst < end) *dst++ = 0; AppMain(); diff --git a/common_arm/Makefile.hal b/common_arm/Makefile.hal index 24d31261e..bfbe56d34 100644 --- a/common_arm/Makefile.hal +++ b/common_arm/Makefile.hal @@ -137,6 +137,9 @@ endif ifneq ($(SKIP_HFPLOT),1) PLATFORM_DEFS += -DWITH_HFPLOT endif +ifeq ($(SKIP_COMPRESSION),1) + PLATFORM_DEFS += -DWITH_NO_COMPRESSION +endif # Standalone mode ifneq ($(strip $(filter $(PLATFORM_DEFS),$(STANDALONE_REQ_DEFS))),$(strip $(STANDALONE_REQ_DEFS))) From bdb384f7b7417a08368ab6cc2a3cfed918641481 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Mon, 28 Dec 2020 22:57:58 +0100 Subject: [PATCH 02/22] Fix for the Makefile.platform file --- armsrc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 074380058..019d10820 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -217,7 +217,7 @@ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z $(Q)$(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=compressed_data $^ $@ $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o -ifneq ($(SKIP_COMPRESSION),1) +ifeq (,$(findstring WITH_NO_COMPRESSION,$(APP_CFLAGS))) $(info [=] LD $@) $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ else From 8b9c6a15f174651e407a77ff843daa19bb68ee87 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 00:44:06 +0100 Subject: [PATCH 03/22] VSCode debugging test --- .vscode/launch.json | 16 +++++++++++++++- .vscode/tasks.json | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f6a030c7c..65619a2a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -55,7 +55,21 @@ "name": "PATH","value": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin" }] } - } + },{ + "type": "cortex-debug", + "request": "launch", + "name": "Debug J-Link", + "cwd": "${workspaceRoot}", + "preLaunchTask": "fullimage: clean & make", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.stage1.elf", + "serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe", + "servertype": "jlink", + "device": "AT91SAM7S512", + "interface": "jtag", + "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. + "runToMain": true, + "armToolchainPath": "/usr/bin/" + } ], "inputs": [ { diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7354a8a2d..4cc21841d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -143,6 +143,14 @@ } }, "problemMatcher": [] + },{ + "label": "fullimage: clean & make", + "type": "shell", + "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", } ], "inputs": [ From 8c29c4231be80b41bc4ee2a31921f4d0c847d9e4 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 03:30:57 +0100 Subject: [PATCH 04/22] Allow generation of debug information when using no compression --- common_arm/Makefile.hal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common_arm/Makefile.hal b/common_arm/Makefile.hal index bfbe56d34..b6519e4ab 100644 --- a/common_arm/Makefile.hal +++ b/common_arm/Makefile.hal @@ -138,7 +138,7 @@ ifneq ($(SKIP_HFPLOT),1) PLATFORM_DEFS += -DWITH_HFPLOT endif ifeq ($(SKIP_COMPRESSION),1) - PLATFORM_DEFS += -DWITH_NO_COMPRESSION + PLATFORM_DEFS += -DWITH_NO_COMPRESSION -g endif # Standalone mode From 654996eeee4f3cd8f1895aa90c57ffc48b04ae63 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 03:39:59 +0100 Subject: [PATCH 05/22] Fixed debugger waiting for main --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 65619a2a3..d1c5d6ff8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -58,7 +58,7 @@ },{ "type": "cortex-debug", "request": "launch", - "name": "Debug J-Link", + "name": "Firmware debug", "cwd": "${workspaceRoot}", "preLaunchTask": "fullimage: clean & make", "executable": "${workspaceRoot}/armsrc/obj/fullimage.stage1.elf", @@ -67,7 +67,7 @@ "device": "AT91SAM7S512", "interface": "jtag", "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. - "runToMain": true, + "runToMain": false, "armToolchainPath": "/usr/bin/" } ], From 2124ef52893d95a251337f385af3ca1d4542e566 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 05:01:29 +0100 Subject: [PATCH 06/22] Added firmware configuration for wsl --- .vscode/launch.json | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d1c5d6ff8..abd2cd775 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -58,10 +58,10 @@ },{ "type": "cortex-debug", "request": "launch", - "name": "Firmware debug", + "name": "(Linux) Firmware debug", "cwd": "${workspaceRoot}", "preLaunchTask": "fullimage: clean & make", - "executable": "${workspaceRoot}/armsrc/obj/fullimage.stage1.elf", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", "serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe", "servertype": "jlink", "device": "AT91SAM7S512", @@ -69,7 +69,21 @@ "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. "runToMain": false, "armToolchainPath": "/usr/bin/" - } + },{ + "type": "cortex-debug", + "request": "launch", + "name": "(WSL) Firmware debug", + "cwd": "${workspaceRoot}", + "preLaunchTask": "fullimage: clean & make", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", + "serverpath": "/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe", + "servertype": "jlink", + "device": "AT91SAM7S512", + "interface": "jtag", + "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. + "runToMain": false, + "armToolchainPath": "/usr/bin/" + } ], "inputs": [ { From 9e224b011b6655e5de59c102731461ffa9adb152 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 14:55:31 +0100 Subject: [PATCH 07/22] Template files for vscode --- .gitignore | 5 + .vscode/extensions.json | 10 ++ .vscode/launch.json | 108 -------------- .vscode/launch_linux.json | 70 +++++++++ .vscode/launch_ps.json | 45 ++++++ .vscode/launch_wsl.json | 70 +++++++++ .vscode/setup.sh | 4 + .vscode/{tasks.json => tasks_linux.json} | 0 .vscode/tasks_ps.json | 177 +++++++++++++++++++++++ .vscode/tasks_wsl.json | 177 +++++++++++++++++++++++ 10 files changed, 558 insertions(+), 108 deletions(-) create mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json create mode 100644 .vscode/launch_linux.json create mode 100644 .vscode/launch_ps.json create mode 100644 .vscode/launch_wsl.json create mode 100644 .vscode/setup.sh rename .vscode/{tasks.json => tasks_linux.json} (100%) create mode 100644 .vscode/tasks_ps.json create mode 100644 .vscode/tasks_wsl.json diff --git a/.gitignore b/.gitignore index 081c0f8e8..1b27c52a3 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,8 @@ fpga_version_info.c # .tmp files are created during compilation *.tmp + +#VSCode files +!.vscode/*.json +.vscode/launch.json +.vscode/tasks.json \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..85b3997e2 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "ms-vscode.cpptools", + "austin.code-gnu-global", + "marus25.cortex-debug", + "augustocdias.tasks-shell-input" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index abd2cd775..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Attach", - "type": "cppdbg", - "request": "attach", - "program": "${cwd}/client/proxmark3", - //"processId": "${command:pickProcess}", - "processId": "${input:ProcessID}", - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "windows": { - "processId": "${input:ProcessIDWindows}", - "miDebuggerPath": "${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe", - "externalConsole": true,//for ProxSpace externalConsole=true is required, because the internal cosole stops updating after a while - "environment": [{ - "name": "PATH","value": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin" - }] - } - },{ - "name": "(gdb) Build & Launch", - "type": "cppdbg", - "request": "launch", - "program": "${cwd}/client/proxmark3", - "args": ["/dev/ttyACM0"], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "preLaunchTask": "client: Debug: clean & make", - "miDebuggerPath": "/usr/bin/gdb", - "windows": { - "args": ["COM5"], - "miDebuggerPath": "${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe", - "externalConsole": true,//for ProxSpace externalConsole=true is required, because the internal cosole stops updating after a while - "environment": [{ - "name": "PATH","value": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin" - }] - } - },{ - "type": "cortex-debug", - "request": "launch", - "name": "(Linux) Firmware debug", - "cwd": "${workspaceRoot}", - "preLaunchTask": "fullimage: clean & make", - "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", - "serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe", - "servertype": "jlink", - "device": "AT91SAM7S512", - "interface": "jtag", - "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. - "runToMain": false, - "armToolchainPath": "/usr/bin/" - },{ - "type": "cortex-debug", - "request": "launch", - "name": "(WSL) Firmware debug", - "cwd": "${workspaceRoot}", - "preLaunchTask": "fullimage: clean & make", - "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", - "serverpath": "/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe", - "servertype": "jlink", - "device": "AT91SAM7S512", - "interface": "jtag", - "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. - "runToMain": false, - "armToolchainPath": "/usr/bin/" - } - ], - "inputs": [ - { - // Using Extension "Tasks Shell Input" https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input - "id": "ProcessID", - "type": "command", - "command": "shellCommand.execute", - "args": { - "command": "pgrep -n proxmark3", - } - - },{ - "id": "ProcessIDWindows", - "type": "command", - "command": "shellCommand.execute", - "args": { - "command": "${workspaceFolder}/../../runme64.bat -c \"cat /proc/$(pgrep -n proxmark3)/winpid\"", - } - - } - ] -} \ No newline at end of file diff --git a/.vscode/launch_linux.json b/.vscode/launch_linux.json new file mode 100644 index 000000000..0f60495a6 --- /dev/null +++ b/.vscode/launch_linux.json @@ -0,0 +1,70 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Client: (gdb) Build & Launch", + "type": "cppdbg", + "request": "launch", + "program": "${cwd}/client/proxmark3", + "args": ["${SerialPort}"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "client: Debug: clean & make", + "miDebuggerPath": "${DebuggerPath}" + },{ + "name": "Client: (gdb) Attach", + "type": "cppdbg", + "request": "attach", + "program": "${cwd}/client/proxmark3", + //"processId": "${command:pickProcess}", + "processId": "${input:ProcessID}", + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + },{ + "name": "Firmware: (J-Link) Build & Launch", + "type": "cortex-debug", + "request": "launch", + "cwd": "${workspaceRoot}", + "preLaunchTask": "fullimage: clean & make", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", + "serverpath": "${JLinkServerPath}", + "servertype": "jlink", + "device": "AT91SAM7S${DeviceMem}", + "interface": "jtag", + "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. + "runToMain": false, + "armToolchainPath": "/usr/bin/" + } + ], + "inputs": [ + { + // Using Extension "Tasks Shell Input" https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input + "id": "ProcessID", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "pgrep -n proxmark3", + } + + } + ] +} \ No newline at end of file diff --git a/.vscode/launch_ps.json b/.vscode/launch_ps.json new file mode 100644 index 000000000..8794ef76e --- /dev/null +++ b/.vscode/launch_ps.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Client: (gdb) Build & Launch", + "type": "cppdbg", + "request": "launch", + "program": "${cwd}/client/proxmark3", + "args": ["${SerialPort}"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ + "name": "PATH","value": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin" + ], + "externalConsole": true,//for ProxSpace externalConsole=true is required, because the internal cosole stops updating after a while + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "client: Debug: clean & make", + "miDebuggerPath": "${DebuggerPath}" + },{ + "name": "Firmware: (J-Link) Build & Launch", + "type": "cortex-debug", + "request": "launch", + "cwd": "${workspaceRoot}", + "preLaunchTask": "fullimage: clean & make", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", + "serverpath": "${JLinkServerPath}", + "servertype": "jlink", + "device": "AT91SAM7S${DeviceMem}", + "interface": "jtag", + "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. + "runToMain": false, + "armToolchainPath": "/usr/bin/" + } + ] +} \ No newline at end of file diff --git a/.vscode/launch_wsl.json b/.vscode/launch_wsl.json new file mode 100644 index 000000000..0f60495a6 --- /dev/null +++ b/.vscode/launch_wsl.json @@ -0,0 +1,70 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Client: (gdb) Build & Launch", + "type": "cppdbg", + "request": "launch", + "program": "${cwd}/client/proxmark3", + "args": ["${SerialPort}"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "client: Debug: clean & make", + "miDebuggerPath": "${DebuggerPath}" + },{ + "name": "Client: (gdb) Attach", + "type": "cppdbg", + "request": "attach", + "program": "${cwd}/client/proxmark3", + //"processId": "${command:pickProcess}", + "processId": "${input:ProcessID}", + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + },{ + "name": "Firmware: (J-Link) Build & Launch", + "type": "cortex-debug", + "request": "launch", + "cwd": "${workspaceRoot}", + "preLaunchTask": "fullimage: clean & make", + "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", + "serverpath": "${JLinkServerPath}", + "servertype": "jlink", + "device": "AT91SAM7S${DeviceMem}", + "interface": "jtag", + "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. + "runToMain": false, + "armToolchainPath": "/usr/bin/" + } + ], + "inputs": [ + { + // Using Extension "Tasks Shell Input" https://marketplace.visualstudio.com/items?itemName=augustocdias.tasks-shell-input + "id": "ProcessID", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "pgrep -n proxmark3", + } + + } + ] +} \ No newline at end of file diff --git a/.vscode/setup.sh b/.vscode/setup.sh new file mode 100644 index 000000000..b439f2cbd --- /dev/null +++ b/.vscode/setup.sh @@ -0,0 +1,4 @@ +export SerialPort="/dev/ttyACM0" +export DebuggerPath="/usr/bin/gdb" +export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" +export DeviceMem="512" \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks_linux.json similarity index 100% rename from .vscode/tasks.json rename to .vscode/tasks_linux.json diff --git a/.vscode/tasks_ps.json b/.vscode/tasks_ps.json new file mode 100644 index 000000000..4cc21841d --- /dev/null +++ b/.vscode/tasks_ps.json @@ -0,0 +1,177 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "all: Make & run", + "type": "shell", + "command": "make -j && ./pm3", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "choose: Make", + "type": "shell", + "command": "make ${input:componentType} -j", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: make", + "type": "shell", + "command": "make client -j DEBUG=1", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: clean & make", + "type": "shell", + "command": "make client/clean && make client -j DEBUG=1", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "fullimage: Make & Flash", + "type": "shell", + "command": "make fullimage && ./pm3-flash-fullimage", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + }, + { + "label": "BOOTROM: Make & Flash", + "type": "shell", + "command": "make bootrom && ./pm3-flash-bootrom", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + }, + { + "label": "Run client", + "type": "shell", + "command": "./pm3", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + },{ + "label": "fullimage: clean & make", + "type": "shell", + "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + } + ], + "inputs": [ + { + "type": "pickString", + "id": "componentType", + "description": "What Makefile target do you want to execute?", + "options": [ + "all", + "client", + "bootrom", + "fullimage", + "recovery", + "clean", + "install", + "uninstall", + "style", + "miscchecks", + "check", + ], + "default": "all" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks_wsl.json b/.vscode/tasks_wsl.json new file mode 100644 index 000000000..4cc21841d --- /dev/null +++ b/.vscode/tasks_wsl.json @@ -0,0 +1,177 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "all: Make & run", + "type": "shell", + "command": "make -j && ./pm3", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "choose: Make", + "type": "shell", + "command": "make ${input:componentType} -j", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: make", + "type": "shell", + "command": "make client -j DEBUG=1", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: clean & make", + "type": "shell", + "command": "make client/clean && make client -j DEBUG=1", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "fullimage: Make & Flash", + "type": "shell", + "command": "make fullimage && ./pm3-flash-fullimage", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + }, + { + "label": "BOOTROM: Make & Flash", + "type": "shell", + "command": "make bootrom && ./pm3-flash-bootrom", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + }, + { + "label": "Run client", + "type": "shell", + "command": "./pm3", + "windows": { + "options": { + "cwd": "${workspaceFolder}/../..", + "shell": { + "executable": "${workspaceFolder}/../../runme64.bat", + "args": [ + "-c \"cd ${workspaceFolderBasename} &&" + ], + + } + } + }, + "problemMatcher": [] + },{ + "label": "fullimage: clean & make", + "type": "shell", + "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + } + ], + "inputs": [ + { + "type": "pickString", + "id": "componentType", + "description": "What Makefile target do you want to execute?", + "options": [ + "all", + "client", + "bootrom", + "fullimage", + "recovery", + "clean", + "install", + "uninstall", + "style", + "miscchecks", + "check", + ], + "default": "all" + } + ] +} \ No newline at end of file From 6f316b8e29559d260f1f3be2ca8b3ce0dd5708f0 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 16:38:02 +0100 Subject: [PATCH 08/22] detect serial port --- .vscode/setup.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++--- pm3 | 45 +++++++++++++++++-------------- 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index b439f2cbd..ee8476d11 100644 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -1,4 +1,65 @@ -export SerialPort="/dev/ttyACM0" -export DebuggerPath="/usr/bin/gdb" -export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" -export DeviceMem="512" \ No newline at end of file +#!/bin/bash +############################### +# Linux # +# Uncomment to override # +############################### +#export SerialPort="/dev/ttyACM0" +#export DebuggerPath="/usr/bin/gdb" +#export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" + +############################### +# WSL # +# Uncomment to override # +############################### +#export SerialPort="/dev/ttyS4" +#export DebuggerPath="/usr/bin/gdb" +#export JLinkServerPath="/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + +############################### +# ProxSpace # +# Uncomment to override # +############################### +#export SerialPort="COM5" +#export DebuggerPath="${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" +#export JLinkServerPath="c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + +#Debugging on 256KB systems is not recommended +#This option does not override PLATFORM_SIZE +export DeviceMem="512" + + +VSCODEPATH=$(dirname "$0") + +function get_serial_port { + if [ -z "$SerialPort" ]; then + pm3list=$($VSCODEPATH/../pm3 --list 2>/dev/null) + #Use first port listed + SerialPort=$(echo $pm3list | head -n 1 | cut -c 4-) + if [ -z "$SerialPort" ]; then + echo >&2 "[!!] No serial port found, please set SerialPort manually" + exit 1 + fi + fi + + echo "Using $SerialPort as port" +} + + +HOSTOS=$(uname | awk '{print toupper($0)}') +if [ "$HOSTOS" = "LINUX" ]; then + if uname -a|grep -q Microsoft; then + echo "WSL" + else + echo "LINUX" + fi +elif [ "$HOSTOS" = "DARWIN" ]; then + echo >&2 "[!!] MacOS not supported, sorry!" + exit 1 +elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then + echo "ProxSpace" +else + echo >&2 "[!!] Host OS not recognized, abort: $HOSTOS" + exit 1 +fi + +get_serial_port \ No newline at end of file diff --git a/pm3 b/pm3 index 0d3b9863a..1ee2ebeb8 100755 --- a/pm3 +++ b/pm3 @@ -14,27 +14,32 @@ PM3PATH=$(dirname "$0") EVALENV="" FULLIMAGE="fullimage.elf" BOOTIMAGE="bootrom.elf" -# try pm3 dirs in current repo workdir -if [ -d "$PM3PATH/client/" ]; then - if [ -x "$PM3PATH/client/proxmark3" ]; then - CLIENT="$PM3PATH/client/proxmark3" - elif [ -x "$PM3PATH/client/build/proxmark3" ]; then - CLIENT="$PM3PATH/client/build/proxmark3" - else - echo >&2 "[!!] In devel workdir but no executable found, did you compile it?" - exit 1 - fi - # Devel mode: point to workdir pm3.py module - EVALENV+=" PYTHONPATH=$PM3PATH/client/src" -# try install dir -elif [ -x "$PM3PATH/proxmark3" ]; then - CLIENT="$PM3PATH/proxmark3" - EVALENV+=" PYTHONPATH=$PM3PATH/../share/proxmark3/pyscripts/" - # or /usr/[local/]lib/python3/dist-packages/pm3.py ? -else -# hope it's installed somehow, still not sure where fw images and pm3.py are... - CLIENT="proxmark3" + +#Skip check if --list is used +if [ ! "$1" == "--list" ]; then + # try pm3 dirs in current repo workdir + if [ -d "$PM3PATH/client/" ]; then + if [ -x "$PM3PATH/client/proxmark3" ]; then + CLIENT="$PM3PATH/client/proxmark3" + elif [ -x "$PM3PATH/client/build/proxmark3" ]; then + CLIENT="$PM3PATH/client/build/proxmark3" + else + echo >&2 "[!!] In devel workdir but no executable found, did you compile it?" + exit 1 + fi + # Devel mode: point to workdir pm3.py module + EVALENV+=" PYTHONPATH=$PM3PATH/client/src" + # try install dir + elif [ -x "$PM3PATH/proxmark3" ]; then + CLIENT="$PM3PATH/proxmark3" + EVALENV+=" PYTHONPATH=$PM3PATH/../share/proxmark3/pyscripts/" + # or /usr/[local/]lib/python3/dist-packages/pm3.py ? + else + # hope it's installed somehow, still not sure where fw images and pm3.py are... + CLIENT="proxmark3" + fi fi + # LeakSanitizer suppressions if [ -e .lsan_suppressions ]; then EVALENV+=" LSAN_OPTIONS=suppressions=.lsan_suppressions" From 5f5e8758ab44d9a20bf2d42bcb6233ba24f501f0 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 17:22:09 +0100 Subject: [PATCH 09/22] Setup for WSL/Linux done --- .gitignore | 5 +- .vscode/setup.sh | 81 ++++++++++++++++++++--- .vscode/{ => templates}/launch_linux.json | 0 .vscode/{ => templates}/launch_ps.json | 0 .vscode/{ => templates}/launch_wsl.json | 0 .vscode/{ => templates}/tasks_linux.json | 0 .vscode/{ => templates}/tasks_ps.json | 0 .vscode/{ => templates}/tasks_wsl.json | 0 8 files changed, 75 insertions(+), 11 deletions(-) rename .vscode/{ => templates}/launch_linux.json (100%) rename .vscode/{ => templates}/launch_ps.json (100%) rename .vscode/{ => templates}/launch_wsl.json (100%) rename .vscode/{ => templates}/tasks_linux.json (100%) rename .vscode/{ => templates}/tasks_ps.json (100%) rename .vscode/{ => templates}/tasks_wsl.json (100%) diff --git a/.gitignore b/.gitignore index 1b27c52a3..125dc536e 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,5 @@ fpga_version_info.c *.tmp #VSCode files -!.vscode/*.json -.vscode/launch.json -.vscode/tasks.json \ No newline at end of file +!.vscode/templates/*.json +!.vscode/extensions.json \ No newline at end of file diff --git a/.vscode/setup.sh b/.vscode/setup.sh index ee8476d11..93f7144f2 100644 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -30,7 +30,7 @@ export DeviceMem="512" VSCODEPATH=$(dirname "$0") -function get_serial_port { +function setup_serial_port { if [ -z "$SerialPort" ]; then pm3list=$($VSCODEPATH/../pm3 --list 2>/dev/null) #Use first port listed @@ -40,26 +40,91 @@ function get_serial_port { exit 1 fi fi - echo "Using $SerialPort as port" } +function setup_gdb_linux { + if [ -z "$DebuggerPath" ]; then + export DebuggerPath="/usr/bin/gdb" + fi + if [ ! -x "$DebuggerPath" ]; then + echo >&2 "[!!] gdb not found, please set DebuggerPath manually" + exit 1 + fi +} + +function setup_jlink_linux { + if [ -z "$JLinkServerPath" ]; then + export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" + fi + if [ ! -x "$JLinkServerPath" ]; then + echo >&2 "[!!] JLinkGDBServerCLExe not found, please set JLinkServerPath manually" + exit 1 + fi + +} + +function setup_jlink_wsl { + if [ -z "$JLinkServerPath" ]; then + export JLinkServerPath="/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + fi + if [ ! -x "$JLinkServerPath" ]; then + echo >&2 "[!!] JLinkGDBServerCLExe not found, please set JLinkServerPath manually" + exit 1 + fi +} + +function setup_wsl { + setup_serial_port + setup_gdb_linux + setup_jlink_wsl + cp "$VSCODEPATH/templates/tasks_wsl.json" "$VSCODEPATH/tasks.json" + envsubst <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json" +} + +function setup_linux { + setup_serial_port + setup_gdb_linux + setup_jlink_linux + cp "$VSCODEPATH/templates/tasks_linux.json" "$VSCODEPATH/tasks.json" + envsubst <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json" +} + +function setup_ps { + setup_serial_port + if [ -z "$JLinkServerPath" ]; then + export JLinkServerPath="c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + fi +} + +if [ -f "$VSCODEPATH/launch.json" ] || [ -f "$VSCODEPATH/tasks.json" ]; then + read -p "Existing configuration found, do you want to override it? " -n 1 -r + if [[ $REPLY =~ ^[Yy]$ ]] + then + rm "$VSCODEPATH/launch.json.bak" 2> /dev/null + rm "$VSCODEPATH/tasks.json.bak" 2> /dev/null + mv "$VSCODEPATH/launch.json" "$VSCODEPATH/launch.json.bak" 2> /dev/null + mv "$VSCODEPATH/tasks.json" "$VSCODEPATH/tasks.json.bak" 2> /dev/null + else + echo >&2 "[!!] user abort" + exit 1 + fi + +fi HOSTOS=$(uname | awk '{print toupper($0)}') if [ "$HOSTOS" = "LINUX" ]; then if uname -a|grep -q Microsoft; then - echo "WSL" + setup_wsl else - echo "LINUX" + setup_linux fi elif [ "$HOSTOS" = "DARWIN" ]; then echo >&2 "[!!] MacOS not supported, sorry!" exit 1 elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then - echo "ProxSpace" + setup_ps else echo >&2 "[!!] Host OS not recognized, abort: $HOSTOS" exit 1 -fi - -get_serial_port \ No newline at end of file +fi \ No newline at end of file diff --git a/.vscode/launch_linux.json b/.vscode/templates/launch_linux.json similarity index 100% rename from .vscode/launch_linux.json rename to .vscode/templates/launch_linux.json diff --git a/.vscode/launch_ps.json b/.vscode/templates/launch_ps.json similarity index 100% rename from .vscode/launch_ps.json rename to .vscode/templates/launch_ps.json diff --git a/.vscode/launch_wsl.json b/.vscode/templates/launch_wsl.json similarity index 100% rename from .vscode/launch_wsl.json rename to .vscode/templates/launch_wsl.json diff --git a/.vscode/tasks_linux.json b/.vscode/templates/tasks_linux.json similarity index 100% rename from .vscode/tasks_linux.json rename to .vscode/templates/tasks_linux.json diff --git a/.vscode/tasks_ps.json b/.vscode/templates/tasks_ps.json similarity index 100% rename from .vscode/tasks_ps.json rename to .vscode/templates/tasks_ps.json diff --git a/.vscode/tasks_wsl.json b/.vscode/templates/tasks_wsl.json similarity index 100% rename from .vscode/tasks_wsl.json rename to .vscode/templates/tasks_wsl.json From 9c43f8e44f379dd5f244f0bbaa3a2730d8d61276 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 17:50:43 +0100 Subject: [PATCH 10/22] Updated wsl instructions --- .../Windows-Installation-Instructions.md | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index ea0505268..6d4477de2 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -149,18 +149,31 @@ Note that it may take a quite long time for a freshly plugged Proxmark3 to be vi Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). -## Color text on windows 10 -In later versions of windows 10 you may be able to get color to work by setting this registry key -``` -[HKEY_CURRENT_USER\Console] - "VirtualTerminalLevel"=dword:00000001 -``` -You also need to disable "use legacy console" in the cmd.exe properties, or set the following registry key -``` -[HKEY_CURRENT_USER\Console] - "ForceV2"=dword:00000001 -``` -After making these changes, you will need to start a new command prompt (cmd.exe) to ensure its using the new settings. -If after making these changes (and restarting proxmark3.exe) you get extra characters and no color text, set either key to 0 or enable legacy mode again (and restart the command prompt). +## (Optional) Visual Studio Code debugging +Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) + +Enter WSL prompt (`wsl` or `start windows terminal`) and from there, follow the [Linux Installation Instructions](/doc/md/Installation_Instructions/Linux-Installation-Instructions.md) for Ubuntu, summarized here below: + +Install dependencies +```sh +sudo apt-get install --no-install-recommends binutils-arm-none-eabi gdb openocd gdb-multiarch +``` + +The J-Link debugger requires `arm-none-eabi-gdb` which was replaced with `gdb-multiarch`. In order to use the J-Link debugger link `arm-none-eabi-gdb` to `gdb-multiarch`: +```sh +sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb +``` + +Setup the Visual Studio Code configuration, by going into your project folder and run: +```sh +./.vscode/setup.sh +``` + +and launch Visual Studio Code +```sh +code . +``` +_note_ +Please install the recommended Visual Studio Code extensions in order for debugging to work. From 800e68d9933bc084e321eed8590ef1862740bc39 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 17:54:49 +0100 Subject: [PATCH 11/22] Missing step --- .../Windows-Installation-Instructions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index 6d4477de2..1cf1f43c9 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -152,6 +152,8 @@ Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmar ## (Optional) Visual Studio Code debugging +Download and install [Visual Studio Code](https://code.visualstudio.com/) + Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) Enter WSL prompt (`wsl` or `start windows terminal`) and from there, follow the [Linux Installation Instructions](/doc/md/Installation_Instructions/Linux-Installation-Instructions.md) for Ubuntu, summarized here below: From d1a6164a10221fd92794adf872e2d34262ab3360 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 18:08:35 +0100 Subject: [PATCH 12/22] Updated linux instructions --- .../Linux-Installation-Instructions.md | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md index 18164398a..aa5cf9042 100644 --- a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md @@ -25,13 +25,16 @@ Install the requirements ```sh sudo apt-get install --no-install-recommends git ca-certificates build-essential pkg-config \ -libreadline-dev gcc-arm-none-eabi libnewlib-dev qtbase5-dev libbz2-dev libbluetooth-dev +libreadline-dev gcc-arm-none-eabi libnewlib-dev qtbase5-dev libbz2-dev libbluetooth-dev \ +binutils-arm-none-eabi gdb openocd gdb-multiarch ``` If you don't need the native Bluetooth support in the client, you can skip the installation of `libbluetooth-dev`. If you don't need the graphical components of the Proxmark3 client (such as in `hw tune`), you can skip the installation of `qtbase5-dev`. +If you don't need the debugging packages, you can skip the installation of `binutils-arm-none-eabi`,`gdb`,`openocd` and `gdb-multiarch`. + If you get some (non blocking) error at runtime such as _Gtk-Message: Failed to load module "canberra-gtk-module"_ you may have to install `libcanberra-gtk-module`. ## On ArchLinux @@ -112,3 +115,25 @@ It must return `ok`. Otherwise this means you've got a permission problem to fix # Compile and use the project Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). + + +## (Optional) Visual Studio Code debugging + +Download and install [Visual Studio Code](https://code.visualstudio.com/) + +Download and install [J-Link Software and Documentation pack](https://www.segger.com/downloads/jlink) + +On some systems `arm-none-eabi-gdb` was replaced with `gdb-multiarch`. In order to use the J-Link debugger you need to link `arm-none-eabi-gdb` to `gdb-multiarch`: +```sh +ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb +``` + +Setup the Visual Studio Code configuration, by going into your project folder and run: +```sh +./.vscode/setup.sh +``` + +now launch Visual Studio Code and open your project folder + +_note_ +Please install the recommended Visual Studio Code extensions in order for debugging to work. From c58b1043b8ca8b9dfb0a0c80ed5ac917502a4cea Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 18:15:09 +0100 Subject: [PATCH 13/22] Make setup executable --- .vscode/setup.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .vscode/setup.sh diff --git a/.vscode/setup.sh b/.vscode/setup.sh old mode 100644 new mode 100755 From cc2b36430dece96f66d0f877ccb55f55fc328d77 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 18:26:51 +0100 Subject: [PATCH 14/22] Fixed removing all variables --- .vscode/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 93f7144f2..3e76e03ae 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -79,7 +79,7 @@ function setup_wsl { setup_gdb_linux setup_jlink_wsl cp "$VSCODEPATH/templates/tasks_wsl.json" "$VSCODEPATH/tasks.json" - envsubst <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json" + envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json" } function setup_linux { @@ -87,7 +87,7 @@ function setup_linux { setup_gdb_linux setup_jlink_linux cp "$VSCODEPATH/templates/tasks_linux.json" "$VSCODEPATH/tasks.json" - envsubst <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json" + envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json" } function setup_ps { From 7c982c7785bbfe45b6d5b783fd5b3e7e04c127fb Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 18:32:22 +0100 Subject: [PATCH 15/22] Print config --- .vscode/setup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 3e76e03ae..1cfd3b9b6 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -30,6 +30,13 @@ export DeviceMem="512" VSCODEPATH=$(dirname "$0") +function print_config { + echo "Updating with following configuration:" + echo "SerialPort: $SerialPort" + echo "DebuggerPath: $DebuggerPath" + echo "JLinkServerPath: $JLinkServerPath" +} + function setup_serial_port { if [ -z "$SerialPort" ]; then pm3list=$($VSCODEPATH/../pm3 --list 2>/dev/null) @@ -40,7 +47,6 @@ function setup_serial_port { exit 1 fi fi - echo "Using $SerialPort as port" } function setup_gdb_linux { @@ -78,6 +84,7 @@ function setup_wsl { setup_serial_port setup_gdb_linux setup_jlink_wsl + print_config cp "$VSCODEPATH/templates/tasks_wsl.json" "$VSCODEPATH/tasks.json" envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json" } @@ -86,6 +93,7 @@ function setup_linux { setup_serial_port setup_gdb_linux setup_jlink_linux + print_config cp "$VSCODEPATH/templates/tasks_linux.json" "$VSCODEPATH/tasks.json" envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json" } @@ -95,6 +103,7 @@ function setup_ps { if [ -z "$JLinkServerPath" ]; then export JLinkServerPath="c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" fi + print_config } if [ -f "$VSCODEPATH/launch.json" ] || [ -f "$VSCODEPATH/tasks.json" ]; then From a103628a351f84521e82521185f8edd18e84612d Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 20:43:24 +0100 Subject: [PATCH 16/22] ProxSpace debugging --- .gitignore | 3 +- .vscode/setup.sh | 32 +++-- .vscode/tasks.json | 102 ++++++++++++++++ .vscode/templates/launch_linux.json | 2 +- .vscode/templates/launch_ps.json | 11 +- .vscode/templates/launch_wsl.json | 2 +- .vscode/templates/tasks_linux.json | 177 ---------------------------- .vscode/templates/tasks_ps.json | 177 ---------------------------- .vscode/templates/tasks_wsl.json | 177 ---------------------------- 9 files changed, 135 insertions(+), 548 deletions(-) create mode 100644 .vscode/tasks.json delete mode 100644 .vscode/templates/tasks_linux.json delete mode 100644 .vscode/templates/tasks_ps.json delete mode 100644 .vscode/templates/tasks_wsl.json diff --git a/.gitignore b/.gitignore index 125dc536e..e1f694327 100644 --- a/.gitignore +++ b/.gitignore @@ -111,4 +111,5 @@ fpga_version_info.c #VSCode files !.vscode/templates/*.json -!.vscode/extensions.json \ No newline at end of file +!.vscode/extensions.json +!.vscode/tasks.json \ No newline at end of file diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 1cfd3b9b6..1dc3b5237 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -21,7 +21,7 @@ ############################### #export SerialPort="COM5" #export DebuggerPath="${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" -#export JLinkServerPath="c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" +#export JLinkServerPath="/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" #Debugging on 256KB systems is not recommended #This option does not override PLATFORM_SIZE @@ -59,6 +59,12 @@ function setup_gdb_linux { fi } +function setup_gdb_ps { + if [ -z "$DebuggerPath" ]; then + export DebuggerPath="${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" + fi +} + function setup_jlink_linux { if [ -z "$JLinkServerPath" ]; then export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" @@ -75,7 +81,17 @@ function setup_jlink_wsl { export JLinkServerPath="/mnt/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" fi if [ ! -x "$JLinkServerPath" ]; then - echo >&2 "[!!] JLinkGDBServerCLExe not found, please set JLinkServerPath manually" + echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually" + exit 1 + fi +} + +function setup_jlink_ps { + if [ -z "$JLinkServerPath" ]; then + export JLinkServerPath="/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + fi + if [ ! -x "$JLinkServerPath" ]; then + echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually" exit 1 fi } @@ -85,7 +101,6 @@ function setup_wsl { setup_gdb_linux setup_jlink_wsl print_config - cp "$VSCODEPATH/templates/tasks_wsl.json" "$VSCODEPATH/tasks.json" envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_wsl.json" > "$VSCODEPATH/launch.json" } @@ -94,26 +109,23 @@ function setup_linux { setup_gdb_linux setup_jlink_linux print_config - cp "$VSCODEPATH/templates/tasks_linux.json" "$VSCODEPATH/tasks.json" envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_linux.json" > "$VSCODEPATH/launch.json" } function setup_ps { setup_serial_port - if [ -z "$JLinkServerPath" ]; then - export JLinkServerPath="c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" - fi + setup_gdb_ps + setup_jlink_ps print_config + envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_ps.json" > "$VSCODEPATH/launch.json" } -if [ -f "$VSCODEPATH/launch.json" ] || [ -f "$VSCODEPATH/tasks.json" ]; then +if [ -f "$VSCODEPATH/launch.json" ]; then read -p "Existing configuration found, do you want to override it? " -n 1 -r if [[ $REPLY =~ ^[Yy]$ ]] then rm "$VSCODEPATH/launch.json.bak" 2> /dev/null - rm "$VSCODEPATH/tasks.json.bak" 2> /dev/null mv "$VSCODEPATH/launch.json" "$VSCODEPATH/launch.json.bak" 2> /dev/null - mv "$VSCODEPATH/tasks.json" "$VSCODEPATH/tasks.json.bak" 2> /dev/null else echo >&2 "[!!] user abort" exit 1 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..463377982 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,102 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "windows": { + "options": { + "cwd": "${workspaceFolder}", + "env": { + "PATH": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin", + "MSYSTEM": "MINGW64" + } + } + }, + "tasks": [ + { + "label": "all: Make & run", + "type": "shell", + "command": "make -j && ./pm3", + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "choose: Make", + "type": "shell", + "command": "make ${input:componentType} -j", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: make", + "type": "shell", + "command": "make client -j DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "client: Debug: clean & make", + "type": "shell", + "command": "make client/clean && make client -j DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + }, + { + "label": "fullimage: Make & Flash", + "type": "shell", + "command": "make fullimage && ./pm3-flash-fullimage", + "problemMatcher": [] + }, + { + "label": "BOOTROM: Make & Flash", + "type": "shell", + "command": "make bootrom && ./pm3-flash-bootrom", + "problemMatcher": [] + }, + { + "label": "Run client", + "type": "shell", + "command": "./pm3", + "problemMatcher": [] + },{ + "label": "fullimage: clean & make debug", + "type": "shell", + "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", + "problemMatcher": [ + "$gcc" + ], + "group": "build", + } + ], + "inputs": [ + { + "type": "pickString", + "id": "componentType", + "description": "What Makefile target do you want to execute?", + "options": [ + "all", + "client", + "bootrom", + "fullimage", + "recovery", + "clean", + "install", + "uninstall", + "style", + "miscchecks", + "check", + ], + "default": "all" + } + ] +} \ No newline at end of file diff --git a/.vscode/templates/launch_linux.json b/.vscode/templates/launch_linux.json index 0f60495a6..5239c6bda 100644 --- a/.vscode/templates/launch_linux.json +++ b/.vscode/templates/launch_linux.json @@ -44,7 +44,7 @@ "type": "cortex-debug", "request": "launch", "cwd": "${workspaceRoot}", - "preLaunchTask": "fullimage: clean & make", + "preLaunchTask": "fullimage: clean & make debug", "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", "serverpath": "${JLinkServerPath}", "servertype": "jlink", diff --git a/.vscode/templates/launch_ps.json b/.vscode/templates/launch_ps.json index 8794ef76e..28b724f7b 100644 --- a/.vscode/templates/launch_ps.json +++ b/.vscode/templates/launch_ps.json @@ -3,6 +3,13 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", + "options": { + "cwd": "${workspaceFolder}", + "env": { + "PATH": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin", + "MSYSTEM": "MINGW64" + } + }, "configurations": [ { "name": "Client: (gdb) Build & Launch", @@ -11,10 +18,6 @@ "program": "${cwd}/client/proxmark3", "args": ["${SerialPort}"], "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [ - "name": "PATH","value": "${workspaceFolder}/../../msys2/mingw64/bin;${workspaceFolder}/../../msys2/usr/local/bin;${workspaceFolder}/../../msys2/usr/bin;${workspaceFolder}/../../msys2/bin" - ], "externalConsole": true,//for ProxSpace externalConsole=true is required, because the internal cosole stops updating after a while "MIMode": "gdb", "setupCommands": [ diff --git a/.vscode/templates/launch_wsl.json b/.vscode/templates/launch_wsl.json index 0f60495a6..5239c6bda 100644 --- a/.vscode/templates/launch_wsl.json +++ b/.vscode/templates/launch_wsl.json @@ -44,7 +44,7 @@ "type": "cortex-debug", "request": "launch", "cwd": "${workspaceRoot}", - "preLaunchTask": "fullimage: clean & make", + "preLaunchTask": "fullimage: clean & make debug", "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", "serverpath": "${JLinkServerPath}", "servertype": "jlink", diff --git a/.vscode/templates/tasks_linux.json b/.vscode/templates/tasks_linux.json deleted file mode 100644 index 4cc21841d..000000000 --- a/.vscode/templates/tasks_linux.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "all: Make & run", - "type": "shell", - "command": "make -j && ./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "choose: Make", - "type": "shell", - "command": "make ${input:componentType} -j", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: make", - "type": "shell", - "command": "make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: clean & make", - "type": "shell", - "command": "make client/clean && make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "fullimage: Make & Flash", - "type": "shell", - "command": "make fullimage && ./pm3-flash-fullimage", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "BOOTROM: Make & Flash", - "type": "shell", - "command": "make bootrom && ./pm3-flash-bootrom", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "Run client", - "type": "shell", - "command": "./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - },{ - "label": "fullimage: clean & make", - "type": "shell", - "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", - "problemMatcher": [ - "$gcc" - ], - "group": "build", - } - ], - "inputs": [ - { - "type": "pickString", - "id": "componentType", - "description": "What Makefile target do you want to execute?", - "options": [ - "all", - "client", - "bootrom", - "fullimage", - "recovery", - "clean", - "install", - "uninstall", - "style", - "miscchecks", - "check", - ], - "default": "all" - } - ] -} \ No newline at end of file diff --git a/.vscode/templates/tasks_ps.json b/.vscode/templates/tasks_ps.json deleted file mode 100644 index 4cc21841d..000000000 --- a/.vscode/templates/tasks_ps.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "all: Make & run", - "type": "shell", - "command": "make -j && ./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "choose: Make", - "type": "shell", - "command": "make ${input:componentType} -j", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: make", - "type": "shell", - "command": "make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: clean & make", - "type": "shell", - "command": "make client/clean && make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "fullimage: Make & Flash", - "type": "shell", - "command": "make fullimage && ./pm3-flash-fullimage", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "BOOTROM: Make & Flash", - "type": "shell", - "command": "make bootrom && ./pm3-flash-bootrom", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "Run client", - "type": "shell", - "command": "./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - },{ - "label": "fullimage: clean & make", - "type": "shell", - "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", - "problemMatcher": [ - "$gcc" - ], - "group": "build", - } - ], - "inputs": [ - { - "type": "pickString", - "id": "componentType", - "description": "What Makefile target do you want to execute?", - "options": [ - "all", - "client", - "bootrom", - "fullimage", - "recovery", - "clean", - "install", - "uninstall", - "style", - "miscchecks", - "check", - ], - "default": "all" - } - ] -} \ No newline at end of file diff --git a/.vscode/templates/tasks_wsl.json b/.vscode/templates/tasks_wsl.json deleted file mode 100644 index 4cc21841d..000000000 --- a/.vscode/templates/tasks_wsl.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "all: Make & run", - "type": "shell", - "command": "make -j && ./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "label": "choose: Make", - "type": "shell", - "command": "make ${input:componentType} -j", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: make", - "type": "shell", - "command": "make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "client: Debug: clean & make", - "type": "shell", - "command": "make client/clean && make client -j DEBUG=1", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [ - "$gcc" - ], - "group": "build", - }, - { - "label": "fullimage: Make & Flash", - "type": "shell", - "command": "make fullimage && ./pm3-flash-fullimage", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "BOOTROM: Make & Flash", - "type": "shell", - "command": "make bootrom && ./pm3-flash-bootrom", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - }, - { - "label": "Run client", - "type": "shell", - "command": "./pm3", - "windows": { - "options": { - "cwd": "${workspaceFolder}/../..", - "shell": { - "executable": "${workspaceFolder}/../../runme64.bat", - "args": [ - "-c \"cd ${workspaceFolderBasename} &&" - ], - - } - } - }, - "problemMatcher": [] - },{ - "label": "fullimage: clean & make", - "type": "shell", - "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", - "problemMatcher": [ - "$gcc" - ], - "group": "build", - } - ], - "inputs": [ - { - "type": "pickString", - "id": "componentType", - "description": "What Makefile target do you want to execute?", - "options": [ - "all", - "client", - "bootrom", - "fullimage", - "recovery", - "clean", - "install", - "uninstall", - "style", - "miscchecks", - "check", - ], - "default": "all" - } - ] -} \ No newline at end of file From 7357d17c8c298042f7ac05341fa71b5d300ef4e6 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 21:02:23 +0100 Subject: [PATCH 17/22] ProxSpace path fixes --- .vscode/setup.sh | 13 +++---------- .vscode/templates/launch_ps.json | 7 ++++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 1dc3b5237..3b652a6b8 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -20,8 +20,7 @@ # Uncomment to override # ############################### #export SerialPort="COM5" -#export DebuggerPath="${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" -#export JLinkServerPath="/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" +#export JLinkServerPath="C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" #Debugging on 256KB systems is not recommended #This option does not override PLATFORM_SIZE @@ -59,12 +58,6 @@ function setup_gdb_linux { fi } -function setup_gdb_ps { - if [ -z "$DebuggerPath" ]; then - export DebuggerPath="${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" - fi -} - function setup_jlink_linux { if [ -z "$JLinkServerPath" ]; then export JLinkServerPath="/opt/SEGGER/JLink/JLinkGDBServerCLExe" @@ -88,9 +81,9 @@ function setup_jlink_wsl { function setup_jlink_ps { if [ -z "$JLinkServerPath" ]; then - export JLinkServerPath="/c/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" + export JLinkServerPath="c:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" fi - if [ ! -x "$JLinkServerPath" ]; then + if [ ! -x $(cygpath \"$JLinkServerPath\") ]; then echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually" exit 1 fi diff --git a/.vscode/templates/launch_ps.json b/.vscode/templates/launch_ps.json index 28b724f7b..045b3d6c5 100644 --- a/.vscode/templates/launch_ps.json +++ b/.vscode/templates/launch_ps.json @@ -15,6 +15,7 @@ "name": "Client: (gdb) Build & Launch", "type": "cppdbg", "request": "launch", + "cwd": "${workspaceFolder}", "program": "${cwd}/client/proxmark3", "args": ["${SerialPort}"], "stopAtEntry": false, @@ -28,13 +29,13 @@ } ], "preLaunchTask": "client: Debug: clean & make", - "miDebuggerPath": "${DebuggerPath}" + "miDebuggerPath": "${workspaceFolder}/../../msys2/mingw64/bin/gdb.exe" },{ "name": "Firmware: (J-Link) Build & Launch", "type": "cortex-debug", "request": "launch", "cwd": "${workspaceRoot}", - "preLaunchTask": "fullimage: clean & make", + "preLaunchTask": "fullimage: clean & make debug", "executable": "${workspaceRoot}/armsrc/obj/fullimage.elf", "serverpath": "${JLinkServerPath}", "servertype": "jlink", @@ -42,7 +43,7 @@ "interface": "jtag", "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. "runToMain": false, - "armToolchainPath": "/usr/bin/" + "armToolchainPath": "${workspaceFolder}/../../msys2/mingw64/bin" } ] } \ No newline at end of file From 3f7e9c8f8279c93a666ff8779cf5317086ce6bc8 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 21:10:16 +0100 Subject: [PATCH 18/22] Windows path check --- .vscode/setup.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index 3b652a6b8..cdfb77e8f 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -83,7 +83,8 @@ function setup_jlink_ps { if [ -z "$JLinkServerPath" ]; then export JLinkServerPath="c:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe" fi - if [ ! -x $(cygpath \"$JLinkServerPath\") ]; then + jlinkpath=$(cygpath "$JLinkServerPath") + if [ ! -x "$jlinkpath" ]; then echo >&2 "[!!] JLinkGDBServerCL.exe not found, please set JLinkServerPath manually" exit 1 fi @@ -107,10 +108,10 @@ function setup_linux { function setup_ps { setup_serial_port - setup_gdb_ps setup_jlink_ps + export DebuggerPath="Using ProxSpace gbd" print_config - envsubst '${SerialPort} ${DebuggerPath} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_ps.json" > "$VSCODEPATH/launch.json" + envsubst '${SerialPort} ${JLinkServerPath} ${DeviceMem}' <"$VSCODEPATH/templates/launch_ps.json" > "$VSCODEPATH/launch.json" } if [ -f "$VSCODEPATH/launch.json" ]; then From c4729670b6c6c79fc968710b18a2b7a2f0860c8d Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 21:37:01 +0100 Subject: [PATCH 19/22] Fixed serial port not parsing --- .vscode/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/setup.sh b/.vscode/setup.sh index cdfb77e8f..70672b924 100755 --- a/.vscode/setup.sh +++ b/.vscode/setup.sh @@ -40,7 +40,7 @@ function setup_serial_port { if [ -z "$SerialPort" ]; then pm3list=$($VSCODEPATH/../pm3 --list 2>/dev/null) #Use first port listed - SerialPort=$(echo $pm3list | head -n 1 | cut -c 4-) + export SerialPort=$(echo $pm3list | head -n 1 | cut -c 4-) if [ -z "$SerialPort" ]; then echo >&2 "[!!] No serial port found, please set SerialPort manually" exit 1 From 9bd73c4c0ad826f144ab5096d71cd275d0e5ccc5 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Tue, 29 Dec 2020 21:43:29 +0100 Subject: [PATCH 20/22] Updated installation instructions for ProxSpace --- .../Windows-Installation-Instructions.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index 1cf1f43c9..80f5b4d5c 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -64,6 +64,24 @@ To use the compiled client, the only differences are that executables end with ` Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). +## (Optional) Visual Studio Code debugging + +Download and install [Visual Studio Code](https://code.visualstudio.com/) + +Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) + +Enter PorxSpace (`runme64.bat`) and enter your project folder. + +Setup the Visual Studio Code configuration, by running: +```sh +./.vscode/setup.sh +``` + +now launch Visual Studio Code and open your project folder + +_note_ +Please install the recommended Visual Studio Code extensions in order for debugging to work. + # Installing on Windows with WSL 1 WSL 1 requires to run on Windows 10 version 1709 or above. Previous windows versions didn't have support for COM ports. From 483707a45ac05ad162705f3022ec6a3e4b09dbd3 Mon Sep 17 00:00:00 2001 From: gator96100 Date: Wed, 30 Dec 2020 00:00:39 +0100 Subject: [PATCH 21/22] Moved vscode instructions --- .../Linux-Installation-Instructions.md | 27 +------ .../VSCode-Installation-Instructions.md | 72 +++++++++++++++++++ .../Windows-Installation-Instructions.md | 48 ------------- 3 files changed, 73 insertions(+), 74 deletions(-) create mode 100644 doc/md/Installation_Instructions/VSCode-Installation-Instructions.md diff --git a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md index aa5cf9042..18164398a 100644 --- a/doc/md/Installation_Instructions/Linux-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Linux-Installation-Instructions.md @@ -25,16 +25,13 @@ Install the requirements ```sh sudo apt-get install --no-install-recommends git ca-certificates build-essential pkg-config \ -libreadline-dev gcc-arm-none-eabi libnewlib-dev qtbase5-dev libbz2-dev libbluetooth-dev \ -binutils-arm-none-eabi gdb openocd gdb-multiarch +libreadline-dev gcc-arm-none-eabi libnewlib-dev qtbase5-dev libbz2-dev libbluetooth-dev ``` If you don't need the native Bluetooth support in the client, you can skip the installation of `libbluetooth-dev`. If you don't need the graphical components of the Proxmark3 client (such as in `hw tune`), you can skip the installation of `qtbase5-dev`. -If you don't need the debugging packages, you can skip the installation of `binutils-arm-none-eabi`,`gdb`,`openocd` and `gdb-multiarch`. - If you get some (non blocking) error at runtime such as _Gtk-Message: Failed to load module "canberra-gtk-module"_ you may have to install `libcanberra-gtk-module`. ## On ArchLinux @@ -115,25 +112,3 @@ It must return `ok`. Otherwise this means you've got a permission problem to fix # Compile and use the project Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). - - -## (Optional) Visual Studio Code debugging - -Download and install [Visual Studio Code](https://code.visualstudio.com/) - -Download and install [J-Link Software and Documentation pack](https://www.segger.com/downloads/jlink) - -On some systems `arm-none-eabi-gdb` was replaced with `gdb-multiarch`. In order to use the J-Link debugger you need to link `arm-none-eabi-gdb` to `gdb-multiarch`: -```sh -ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb -``` - -Setup the Visual Studio Code configuration, by going into your project folder and run: -```sh -./.vscode/setup.sh -``` - -now launch Visual Studio Code and open your project folder - -_note_ -Please install the recommended Visual Studio Code extensions in order for debugging to work. diff --git a/doc/md/Installation_Instructions/VSCode-Installation-Instructions.md b/doc/md/Installation_Instructions/VSCode-Installation-Instructions.md new file mode 100644 index 000000000..079f301f6 --- /dev/null +++ b/doc/md/Installation_Instructions/VSCode-Installation-Instructions.md @@ -0,0 +1,72 @@ +# Visual Studio Code for debugging + +Download and install [Visual Studio Code](https://code.visualstudio.com/) + +Download and install [J-Link Software and Documentation pack](https://www.segger.com/downloads/jlink) + + +## Debian / Ubuntu / Kali / ParrotOS / Raspbian + +Install dependencies + +```sh +sudo apt-get install --no-install-recommends binutils-arm-none-eabi gdb openocd gdb-multiarch +``` + +On some systems `arm-none-eabi-gdb` was replaced with `gdb-multiarch`. In order to use the J-Link debugger you need to link `arm-none-eabi-gdb` to `gdb-multiarch`: +```sh +ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb +``` + +Setup the Visual Studio Code configuration, by going into your project folder and run: +```sh +./.vscode/setup.sh +``` + +now launch Visual Studio Code and open your project folder + + +## Windows: WSL + +Enter WSL prompt (`wsl` or `start windows terminal`) + +Install dependencies +```sh +sudo apt-get install --no-install-recommends binutils-arm-none-eabi gdb openocd gdb-multiarch +``` + +The J-Link debugger requires `arm-none-eabi-gdb` which was replaced with `gdb-multiarch`. In order to use the J-Link debugger link `arm-none-eabi-gdb` to `gdb-multiarch`: +```sh +sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb +``` + +Setup the Visual Studio Code configuration, by going into your project folder and run: +```sh +./.vscode/setup.sh +``` + +and launch Visual Studio Code +```sh +code . +``` + + +## Windows: ProxSpace + +Download and install [Visual Studio Code](https://code.visualstudio.com/) + +Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) + +Enter PorxSpace (`runme64.bat`) and enter your project folder. + +Setup the Visual Studio Code configuration, by running: +```sh +./.vscode/setup.sh +``` + +now launch Visual Studio Code and open your project folder + + + +_note_ +Please install the recommended Visual Studio Code extensions in order for debugging to work. \ No newline at end of file diff --git a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md index 80f5b4d5c..6000f42f2 100644 --- a/doc/md/Installation_Instructions/Windows-Installation-Instructions.md +++ b/doc/md/Installation_Instructions/Windows-Installation-Instructions.md @@ -64,24 +64,6 @@ To use the compiled client, the only differences are that executables end with ` Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). -## (Optional) Visual Studio Code debugging - -Download and install [Visual Studio Code](https://code.visualstudio.com/) - -Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) - -Enter PorxSpace (`runme64.bat`) and enter your project folder. - -Setup the Visual Studio Code configuration, by running: -```sh -./.vscode/setup.sh -``` - -now launch Visual Studio Code and open your project folder - -_note_ -Please install the recommended Visual Studio Code extensions in order for debugging to work. - # Installing on Windows with WSL 1 WSL 1 requires to run on Windows 10 version 1709 or above. Previous windows versions didn't have support for COM ports. @@ -167,33 +149,3 @@ Note that it may take a quite long time for a freshly plugged Proxmark3 to be vi Now you're ready to follow the [compilation instructions](/doc/md/Use_of_Proxmark/0_Compilation-Instructions.md). - -## (Optional) Visual Studio Code debugging - -Download and install [Visual Studio Code](https://code.visualstudio.com/) - -Download and install [J-Link Software and Documentation pack for Windows](https://www.segger.com/downloads/jlink/JLink_Windows.exe) - -Enter WSL prompt (`wsl` or `start windows terminal`) and from there, follow the [Linux Installation Instructions](/doc/md/Installation_Instructions/Linux-Installation-Instructions.md) for Ubuntu, summarized here below: - -Install dependencies -```sh -sudo apt-get install --no-install-recommends binutils-arm-none-eabi gdb openocd gdb-multiarch -``` - -The J-Link debugger requires `arm-none-eabi-gdb` which was replaced with `gdb-multiarch`. In order to use the J-Link debugger link `arm-none-eabi-gdb` to `gdb-multiarch`: -```sh -sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb -``` - -Setup the Visual Studio Code configuration, by going into your project folder and run: -```sh -./.vscode/setup.sh -``` - -and launch Visual Studio Code -```sh -code . -``` -_note_ -Please install the recommended Visual Studio Code extensions in order for debugging to work. From f4c632bd313172ea7620f565f8ae048d3dbb262e Mon Sep 17 00:00:00 2001 From: gator96100 Date: Wed, 30 Dec 2020 00:19:21 +0100 Subject: [PATCH 22/22] Added DEBUG_ARM flag --- .vscode/tasks.json | 2 +- Makefile.defs | 5 +++++ common_arm/Makefile.hal | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 463377982..67f0f235e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -71,7 +71,7 @@ },{ "label": "fullimage: clean & make debug", "type": "shell", - "command": "make armsrc/clean && make armsrc/all SKIP_COMPRESSION=1 DEBUG=1", + "command": "make armsrc/clean && make armsrc/all DEBUG_ARM=1", "problemMatcher": [ "$gcc" ], diff --git a/Makefile.defs b/Makefile.defs index 48567214b..b86b477aa 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -66,6 +66,11 @@ else DEFCFLAGS = -Wall -Werror -O3 -fstrict-aliasing -pipe DEFLDFLAGS = endif + +ifeq ($(DEBUG_ARM),1) + APP_CFLAGS += -g + SKIP_COMPRESSION=1 +endif # Next ones are activated only if SANITIZE=1 ifeq ($(SANITIZE),1) DEFCFLAGS += -g -fsanitize=address -fno-omit-frame-pointer diff --git a/common_arm/Makefile.hal b/common_arm/Makefile.hal index b6519e4ab..bfbe56d34 100644 --- a/common_arm/Makefile.hal +++ b/common_arm/Makefile.hal @@ -138,7 +138,7 @@ ifneq ($(SKIP_HFPLOT),1) PLATFORM_DEFS += -DWITH_HFPLOT endif ifeq ($(SKIP_COMPRESSION),1) - PLATFORM_DEFS += -DWITH_NO_COMPRESSION -g + PLATFORM_DEFS += -DWITH_NO_COMPRESSION endif # Standalone mode