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

Integrating Raspberry Baremetal build #912

Closed
msx80 opened this issue Aug 21, 2019 · 16 comments
Closed

Integrating Raspberry Baremetal build #912

msx80 opened this issue Aug 21, 2019 · 16 comments
Assignees

Comments

@msx80
Copy link
Contributor

msx80 commented Aug 21, 2019

Hi there, to continue discussion on #907 , i made some tests and updated the build of my baremetal port to the latest TIC80 sources.

In the end, modifications on the codebase is limited to the following:

  • fs.c: this is the biggest change, most of the primitive functions in here need a different implementation.
  • tic80_types.h: need changes to avoid a type conflict.
  • CMakeList.txt: a block for Baremetal is added at the beginning as a preamble, to set all variables etc.

Everything else is new files that could go in any folder.
The strategy i used is to build tic80lib as usual (i haven't added a new target) with BAREMETAL switch, which is basically just crosscompiling it to ARM with some custom stuff for RPI. Then i made a separate program (the kernel), based on circle examples code, that link to the tic80lib.a. This is a separate Makefile that include stuff from circle and circle-stdlib, not sure it is possible to include it in the main CMake build file.

I think we could put the kernel on src/system/baremetalrpi and the Makefile on build/baremetalrpi, or some similar combination. In build/baremetalrpi i can put a readme with all steps to checkout circle and build everything.

If you're ok i can prepare a pull request (in a couple of weeks, i'm leaving for vacation soon :D ). Obviously everything can be changed later if we find a better fit.

I was able to build TIC80 with all languages except squirrel (for some reason it breaks crosscompilation, i think it has some dangling arm switch inside somewhere).

@nesbox
Copy link
Owner

nesbox commented Aug 22, 2019

Sounds awesome, as for fs.c I think we could make some kind of abstraction layer for the file system operations, will do after your PR...
Thank you.

@nesbox nesbox self-assigned this Sep 27, 2019
@nesbox nesbox added this to the 0.80.0 milestone Sep 27, 2019
@nesbox
Copy link
Owner

nesbox commented Sep 27, 2019

will setup CI scripts soon
thanks

@msx80
Copy link
Contributor Author

msx80 commented Sep 28, 2019

Hi there, you may want to wait for my next pr (with some more hardware support) before setting up ci, as the building instructions have changed a little

@nesbox nesbox removed this from the 0.80.0 milestone Jul 15, 2020
@nesbox
Copy link
Owner

nesbox commented Nov 2, 2020

Hi,
I tried to setup CI for the bare-metal build but with no success, seems we are a bit outdated with the Circle repo now.
@msx80 could you pls look at?
Thank you.

@msx80
Copy link
Contributor Author

msx80 commented Nov 12, 2020

Hi there, i'll take a look! With RPi4 and RPI400 it starts to get interesting.
But i'll take some time as i'm a bit busy lately..

@nesbox
Copy link
Owner

nesbox commented Nov 13, 2020

Hi, thank you 👍

@msx80
Copy link
Contributor Author

msx80 commented Nov 24, 2020

I gave a try, i've updated some stuff and can compile some of the libs, but zip is giving me errors.

In file included from /home/nicola/TIC-80/vendor/zip/src/zip.c:47: /home/nicola/TIC-80/vendor/zip/src/miniz.h: In function 'mz_zip_set_file_times': /home/nicola/TIC-80/vendor/zip/src/miniz.h:4479:11: error: implicit declaration of function 'utime'; did you mean 'ctime'? [-Werror=implicit-function-declaration] 4479 | return !utime(pFilename, &t); | ^~~~~ | ctime cc1: all warnings being treated as errors

Seems some shenanigans with utime.h. In miniz.h there's a switch that seems to be added just for that (MINIZ_NO_TIME), but if i define it, some other things break:

In file included from /home/nicola/TIC-80/vendor/zip/src/zip.c:47: /home/nicola/TIC-80/vendor/zip/src/miniz.h: In function 'mz_zip_writer_add_file': /home/nicola/TIC-80/vendor/zip/src/miniz.h:6331:8: error: implicit declaration of function 'mz_zip_get_file_modified_time' [-Werror=implicit-function-declaration] 6331 | if (!mz_zip_get_file_modified_time(pSrc_filename, &file_modified_time)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [...]

I'm not sure what to make of it, seems like it doesn't handle the switch correctly as it still uses some functions that are switched off. I've tried to update to the latest version of the library but the behaviour doesn't change.

I'll look deeper into it when i'll have some more time, in the meantime i report the progress, if anyone has some idea it's welcome :D

@nesbox
Copy link
Owner

nesbox commented Nov 24, 2020

I'll try to fork the zip lib and fix it asap...

@nesbox
Copy link
Owner

nesbox commented Nov 26, 2020

I've fixed the compilation with MINIZ_NO_TIME here fc28282, pls update submodules.
@msx80

@msx80
Copy link
Contributor Author

msx80 commented Nov 26, 2020

Thanks @nesbox! After spending some time on it i have good news: i was able to build and run tic80 again! :)
I'm sure the build system could be cleaned up a lot (i went through trial and error), but it's working, and i haven't touched anything outside of my folders, other than the main CMakeLists.txt

Now, i have the weirdest bug on keyboard input: i don't seems to be able to type anything on either the console or the code window. Keyboard is working and tic80 is responding to some keystrokes: cursors, function keys, ENTER, CTRL-R, CTRL-C/V/X, delete, backspace all works, but if i type any command like "ls" or "run", nothing appears (when i hit ENTER it gets me a new line but no text).
Since CTRL-R is working, i would expect to be able to type the letter R. Any idea on what could cause this behaviour ?

PS when i get it working, should i submit the changes via PR ?

nesbox added a commit that referenced this issue Nov 26, 2020
@nesbox
Copy link
Owner

nesbox commented Nov 26, 2020

Awesome news!!! :)
I think I know the reason for the keyboard bug and just pushed a fix 68015d1.
Pls submit the changes via PR if not difficult. Will it work with the Github Actions?
Thank you.

nesbox added a commit that referenced this issue Nov 27, 2020
nesbox added a commit that referenced this issue Nov 27, 2020
@msx80
Copy link
Contributor Author

msx80 commented Nov 27, 2020

I had the feeling it was some bug on the mainstream :)

I'll submit via PR, no problem. As soon as i fix a couple of bugs on file access.

Sorry but i'm totally ignorant about Github Actions and CI in general, no idea how they work. I'll update the baremetal build guide with the new procedure, it's mostly executing configure and make scripts and the like. The step where you have to change a file is gone i think.

@nesbox
Copy link
Owner

nesbox commented Nov 27, 2020

I'll add Github Actions myself if you provide detailed build instructions, no problems here.
Thanks.

@msx80
Copy link
Contributor Author

msx80 commented Nov 27, 2020

Ok, it works now, i located that nasty memory corruption bug (took a whole day but ok) and it's ok. The build process is updated, as long as you can run arbitrary commands on Actions, it should be possible to add it.

I'll fix some remaining minor issues in the future. Hopefully after putting my hands on a RPi4 (or 400)

@nesbox
Copy link
Owner

nesbox commented Nov 28, 2020

Merged, will try to setup CI soon.
Thank you.

nesbox added a commit that referenced this issue Dec 1, 2020
@nesbox
Copy link
Owner

nesbox commented Dec 1, 2020

Baremetal build added to Github Actions a4df306.

@nesbox nesbox closed this as completed Dec 1, 2020
This issue was closed.
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

No branches or pull requests

2 participants