adafruit / uf2-samdx1

MSC bootloader (based on UF2) for SAMD21
Other
210 stars 182 forks source link

Reading logs - how???? #197

Open davepruitt opened 1 year ago

davepruitt commented 1 year ago

I am having some issues with the bootloader and it would be helpful to get logging working. Unfortunately, there is not really any explanation or tutorial on how to read the logs that the bootloader generates.

In uf2.h, I have set USE_LOGS to be equal to 1:

#define USE_LOGS 1

I have noticed from reading utils.c and uf2.h that the logs seem to just be stored in a 4096 byte memory buffer. From uf2.h:

struct LogStore {
    int ptr;
    char buffer[4096];
};
extern struct LogStore logStoreUF2;

From utils.c:

struct LogStore logStoreUF2;

Is there an easy way to read these logs from my computer? If the response is "use OpenOCD", that doesn't really give me any more information. Are there any tutorials or documentation anywhere about how to read those logs?

My setup:

The specific issues I am having with the bootloader (the reasons why I want to get logging working):

dhalbert commented 1 year ago

The logging mechanism was developed by the original authors of this code at Microsoft. I too have made some attempt to use the logging, but didn't quite succeed. In the scripts/ directory there is some Javascript code that may be informative. If that doesn't help, you could inquire in an issue in the original repo: https://github.com/microsoft/uf2-samdx1

mfvmx commented 3 months ago

I was able to get it to work by installing node.js and slightly changing the dbdtool.js to point to my arduino openocd install directory by making this change:

    // let openocdPath = pkgDir + "tools/openocd/0.10.0-arduino1-static/"
    let openocdPath = pkgDir + "tools/openocd/0.11.0-arduino2/"

Then updating the file search in dbdtool.js to this:

        for (let ln of mapFile.split(/\r?\n/)) {
            // let m = /^\s*0x00000([0-9a-f]+)\s+(\S+)/.exec(ln)
            let m = /^\s*0x0*([0-9a-f]+)\s+(\S+)/.exec(ln);
            if (m && m[2] == logSym) {

Then running this in the command prompt:

node dbgtool.js firmware.map