-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Good ways to debug and emulate the firmware under Unix? #276
Comments
During the years I've been debugging the Chameleon in different ways, depending on the situation When applicable, the easiest thing to do is to compile the code as a x86 application and debug that. It might be useful when trying to validate a single function with different inputs (we did it for Debugging asynchronous functions such as ISRs is way more complex due to the precise timing required and breakpoints/logging would interfere with the other operations, breaking the software while trying to debug it. Imagine breaking on a function which is called every 20 us to sample data on the carrier: on the second hit you'd be unsynchronised to the external clock. Ultimately, if you really need functions/data breakpoints you can use an ICE such as Atmel ICE which is supported by Also, you can debug with Atmel Studio which is, admittedly, much more powerful and stable than avarice. You don't need to build the codebase with Atmel Studio, but you can import separately the source and the elf built with |
@ceres-c I have previously tried using simavr with no luck due to apparently broken support for the XMega chips. It could also be that I changed too many settings with my DESFire code (to get some extra stack space) and it doesn't know how to handle that setup. Just to follow up, my active setup has been to use |
You could use the Atmel ICE to flash the MCU and debug it, but you wouldn't be able to communicate with it unless you heavily edit the current codebase since, if I'm not mistaken, the telnet interface is exposed only through USB. You would still need a working USB connector By the way me and @MrMoDDoM hit that logging behavior as well while debugging other stuff |
@ceres-c It's been an issue for a while that I stumbled over with my Android app. It comes up there since the toolbar auto-refreshes the config and UID information every few seconds, which means that there is a handler going off regularly to call a terminal command. On the other hand, calling asynchronously scheduled commands as normal with the app that have logging commands in them also would have (in previous code) had flushes and writes to serial USB in the middle of some of the scheduled handler code returning data over USB. Kaboom! It collides and things get reported in jumbled order. I had to figure out a solution pretty early on this summer to use my testing setup with the firmware. Basically, the solution is to add anything printed to logs to a small linked list, and then only print this at a new LiveLogTick in the main loop. Also, for whatever this is worth, it makes me wonder why we are using so many structures in the default LUFA configuration. One of the big things I had to change to make space for crypto storage compendia and stuff is to reduce the LUFA config by one massive (approx 400 bytes!) |
Hi @maxieds and @ceres-c, yes a separate PT for the logmode functionality would of course be great. Independent of that, we'd definitely consider also merging the DESFire code at some point - maybe as an optional feature (e.g. through Makefile defines) and not in the default build to address possible license issues and code size problems. We'll have to discuss that a bit internally. |
@david-oswald When you decide how this will get handled, please also advise me how best to submit a PR this large, and if there are any other procedures that would help with easing this transition. For reference, I have had to change the RevG Makefile source considerably for my mods of the firmware. I would have to check, but it's possible that some things were also changed in the LUFA/Build/lufa_build.mk source as well. This should be more minor than the primary Makefile changes though. There is also some limited support for new terminal commands that are wrapped in defines so that they only get compiled in when the DESFire support is enabled in the I should be able to file an initial pull request to get the LIVE logging functionality changes in soon (maybe later today). I also still think it's worth looking at whether enabling all of those LUFA Endpoint structures is actually necessary. It might be possible to get away with only 1-2 of them, say one for serial USB transfers, and possibly another for the RF transfers if that is how that functionality is working. This is by far based on my reads of |
I also wonder about things like where best to place the libnfc testing code sources so users can (if they so choose) verify continued support for the functionality. Maybe this could get placed in the lower level |
A hint as to whether or not this many LUFA |
Plus 2 endpoints from this line:
However it may be possible to reduce the endpoint buffer size, if I am not mistaken. |
@david-oswald |
I am running into a number of complications finely tuning and testing the DESFire emulation support mentioned in #218. All of the solutions I have seen running
gdb
withavr-gcc
related tools are either dated at this point of do not have working integrated support for the ATXMega chips on the Chameleon devices. I see you all merging pull request after pull request here. Can some of the core developers shed some light on how they debug when writing new tag implementations for the firmware?The DESFire support is notably and necessarily more complicated, with many more branches to take through the code, than any of the other tag emulation support I have seen so far. It's getting to the point where I'm spending 2/3 of my time on the project just re-flashing to see a couple of debug messages printed slowly over live logging. It would be very nice to simulate and set breakpoints, etc, and restart the firmware quickly when something inevitably crashes out.
Thanks ahead of time.
The text was updated successfully, but these errors were encountered: