Skip to content
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

Qemu #515

Merged
merged 5 commits into from Apr 24, 2014
Merged

Qemu #515

merged 5 commits into from Apr 24, 2014

Conversation

errordeveloper
Copy link
Contributor

No description provided.

@errordeveloper
Copy link
Contributor Author

Travis says hello!

@errordeveloper
Copy link
Contributor Author

I'm thinking it'll be possible to add a FAT SD card image with the full test suite, passing it with -sd flag to Qemu. That would require writing a script that generates the FAT image and then making it work with SPI/SDIO and the filesystem library within Qemu...

@pfalcon
Copy link
Contributor

pfalcon commented Apr 21, 2014

So, does mainline qemu includes Cortex-M support now? I saw Cortex-M port somewhere, but it would be pleasant surprise to see it in mainline. Anyway, having some README for qemu port with basic info and instructions would help.

@dpgeorge
Copy link
Member

This port looks very similar to bare-arm. Is the only new addition the run line in the Makefile?

@dpgeorge
Copy link
Member

Well, of course there are a few other changes, but I mean to say that is it necessary to have a separate port for something so similar to bare-arm?

@errordeveloper
Copy link
Contributor Author

@dpgeorge true, it's very similar to the bare-arm. I was debating what to do, once I
thoight of adding filesystem and SD card image, it made sense to keep it a
separate port. So the idea would be that bare-arm remains the reference
point with minimum feature set, while qemu-arm would be for automated
testing.

@errordeveloper
Copy link
Contributor Author

@pfalcon yes, it's been there for a while actually. It currently consists of 2 old
Stellaris devices, but M0 and M0+ support is coming 1. Interestingly, there is also
Ethernet emulation for Stellaris, which should be relatively easy to get
to work with lwIP, but I'd rather not spend the time to provide what would
effectively be a Stellaris M3 port... There are newer Tiva C devices that
are of more interest.

@pfalcon
Copy link
Contributor

pfalcon commented Apr 24, 2014

Just in case, +1 from me, this is pure magic, and @errordeveloper's reasons for having this a separate port make sense (assuming he intends to work on it further).

@errordeveloper
Copy link
Contributor Author

@pfalcon, surely I'd like to implement a way of running tests/*/*.py inside the Qemu. The only dilemma I've got is whether to do it by means of using a SD card emulation with FAT filesystem implementation involved and SPI/SDIO driver to be figured out or generating C code that would concatenate those scripts into test case C functions with script themselves being really just inline string. I believe there is no limitation to length of statically allocated string and I should be able to set any size of RAM and flash with Qemu... Any thoughts on that would appreciated. The second approach seems simpler to me, although first approach would also test FAT library to some extend, but testing the library would be inexplicit and seems like an unnecessary development overhead.
With the first approach I'd need to implement a code generator with one script, which with second I'll need to script creation of FAT filesystem image that might require a partition table and some other jazz and then integrate the FAT library with SPI driver and that would effectively have to target the Stellaris SPI and I'm not hugely interested in providing a port for this legacy piece of silicon. I mean, perhaps it would match up with the Tiva SPI, but not that I have a desire to figure that out. Although, it might be quite simple and I could dig in... Not quite sure though, and really would love to here your thoughts. On the other had there might be other approaches and potentially getting UART working two ways via Qemu standard I/O might be another seemingly easy approach, but it might require something else, like allocating memory to store input scripts or something... hm. I have already considered using Ethernet emulation and hook the test framework to some sort of RPC over a socket, but that's an even bigger stretch. Any other thoughts? Potentially one could shovel the script's straight into Qemu's representation of target's RAM, but that's quite a waste of a hack... Just brainstorming really ;)

Regarding this pull-request, I don't intend to provide the implementations of test suite here, this is suppsed to make sense on it's own. I can update the top-level README to describe this port in general terms. There is in fact one important details, this was specifically tailored to ARM's version of GCC, and not the Mentor Graphics one. It turned out that linker scripts are quite a bit of a different story, which is something I attempted to note in the makefile already.

@lurch
Copy link
Contributor

lurch commented Apr 24, 2014

Regarding the test-scripts, can't you just do it the way pyboard does?
I don't have a physical pyboard yet, but looking at run-tests.py it seems to just send each test one at a time over a UART connection? Which should be much easier than emulating an SD card.

@dpgeorge
Copy link
Member

I don't have a physical pyboard yet

Sorry about that... I'm working on that problem right now!

dpgeorge added a commit that referenced this pull request Apr 24, 2014
@dpgeorge dpgeorge merged commit 5be40af into micropython:master Apr 24, 2014
@lurch
Copy link
Contributor

lurch commented Apr 24, 2014

Sorry about that... I'm working on that problem right now!

LOL, no rush. Just getting to grips with the unix port of uPy is keeping me busy enough ;-)
(I got my parsenum fixes all finished and fully tested last night, but I'll be too busy to tidyup and pullrequest until next week)

pfalcon pushed a commit that referenced this pull request May 7, 2014
This is primarily intended to provide testing of Thumb-specific code within
Travis CI as well as if anyone else want to run it locally.  As discussed in
purposes.  This is currently agains an emulated Cortex-M3 core, however in
the near future it can extended to support M0, M0+ as well M4 (work in
progress exists in sushihangover/qemu).

It's probably true that most of the code base can be covered running uPy
natively on a POSIX system, however we do have the tiny bit of assembly
code.  There may exist bugs related to endianness and type aliases, let
alone potential standard library or compiler bugs or even
architecture-specific optimisations.

This could also incorporate lwIP (or other TCP/IP stack) integration as well
as SDIO+FATFS drivers.

The solution to inline the test cases was chose due to simplicity. It could
alternatively be implemented in a number of different way (see #515), but
this looked the simplest.

Inclusion of tinytest was just to avoid writing boilerplate code for
counting failed tests and other utility functions.  Currently only a few
functions are used, however this could be extended.  Checking in the code
instead of using submodule was a personal preference, but if people do want
the pain of submodules, this can provided.  This particular framework is
also pretty good if one desires to run unit test on target.  The approach
with scripts being inlined is probably not quite suited for the size of
memory an MCU has, but the tinytest itself should be good, if lower-level C
code is to be unit tested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants