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

Baremetal Pi fix #2763

Merged
merged 10 commits into from
Mar 22, 2025
Merged

Baremetal Pi fix #2763

merged 10 commits into from
Mar 22, 2025

Conversation

josei
Copy link
Contributor

@josei josei commented Mar 17, 2025

Raspberry Pi baremetal versions have been broken for a while.

I've been doing extensive testing on a recently-purchased Raspberry PI 3 (which wasn't supported by any of the existing releases, not even v0.90, unlike older Raspberry PI 3 boards, which I know should be the same hardware but it looks they're not).

I finally found that simply including the reference to fopen/fclose commands in the bytebattle code in studio.c breaks the build and makes it not go past the 4 color gradient firmware screen. Commenting out this code fixes it.

There was an additional bug about tic80 folder check always returning false under baremetal. This bug was easier to find thanks to logs working again after the previous change.

Additionally, the build only boots with just LUA support, so the next cmake command is required:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_LUA=ON -DBUILD_WITH_MOON=OFF -DBUILD_WITH_FENNEL=OFF -DBUILD_WITH_WREN=OFF -DBUILD_WITH_RUBY=OFF -DBUILD_WITH_WASM=OFF -DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_SQUIRREL=OFF -DBUILD_WITH_PYTHON=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_JANET=OFF ..

More research is needed to fix the rest of languages.

Sample build rpi3-baremetal.zip. The compiler version I used is arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-eabi.

Additional bugs that are fixed in this PR for the Baremetal version:

  • Removed pixel cursor (not needed anymore since a cursor is rendered by TIC-80).
  • del command now supports deleting files and folders.
  • .local folder is hidden from console (simply moved to parent folder outside tic80).
  • tic80.com option is not shown, as baremetal has currently no network support.
  • Support USB storage if plugged in at boot (fall back to SD card if no external storage is found).
  • Added locale support for ES type layout (pass -DKEYBOARD_LAYOUT=ES to cmake to use it). It also requires disabling ALT+2 and ALT+3 shortcuts, as otherwise there's no way to write @ and # symbols. Layouts for more languages can be added in the future (although they require recompiling).
  • Fixed potential buffer overflow if pressing too many keys at the same time (use TIC80_KEY_BUFFER limit).
  • Fixed missing mouse-up event.

const char* path = tic_fs_path(fs, name);

const FsString* pathString = utf8ToString(path);
#if defined(BAREMETALPI)
return f_unlink(pathString);
#else
bool result = tic_remove(pathString);
freeString(pathString);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to free the string in BOTH cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed in e8ac15d.

return 0;
const char* path = tic_fs_path(fs, name);
const FsString* pathString = utf8ToString(path);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure you also need to free here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e8ac15d.

src/studio/fs.c Outdated
@@ -548,8 +550,7 @@ static void onEnumPublicDirsDone(void* data)
bool fs_isdir(const char* path)
{
#if defined(BAREMETALPI)
// This function isn't applicable to baremetal.
return false;
return fs_exists(path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly the same as "is directoy" since it's only checking for existence, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed in e8ac15d.

Comment on lines 422 to +424
static const char Symbols[] = " abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;'`,./ ";
static const char Shift[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ)!@#$%^&*(_+{}|:\"~<>? ";
static const char Alt[] = " ";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the "default" (other than ES) not match the lines removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been refactored for clarity, since the caps boolean only reverses shift condition, and the ternary conditional operator was already too complex even without the alt modifier.

@@ -1827,6 +1841,7 @@ static void processShortcuts(Studio* studio)
#if defined(BUILD_EDITORS)
else if(studio->mode != TIC_RUN_MODE && studio->config->data.keyboardLayout != tic_layout_azerty)
{
#ifndef KEYBOARD_LAYOUT_ES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this only apply to ES layout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ES layout, ALT+1 outputs |, ALT+2 outputs @, and ALT+3 outputs #. With those shortcuts in place (which can be still accessed using ESC, F1, F2, F3, etc.), there's no way to type symbols |, @, or #.

@joshgoebel
Copy link
Collaborator

Breaking work like this up into smaller commits could make it easier to review in the future.

@josei
Copy link
Contributor Author

josei commented Mar 18, 2025

Breaking work like this up into smaller commits could make it easier to review in the future.

Thanks for the advice. I rebuilt the commit history to make it easier to understand.

@nesbox nesbox merged commit 91800e0 into nesbox:main Mar 22, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants