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

bootup logos for pinecil v2 #32

Closed
mythicaleinhorn opened this issue Dec 23, 2022 · 19 comments
Closed

bootup logos for pinecil v2 #32

mythicaleinhorn opened this issue Dec 23, 2022 · 19 comments

Comments

@mythicaleinhorn
Copy link

I was wondering how to upload a bootup logo to the pinecil v2.
When I use the update instructions from the Pine64 wiki, I end up overwriting the whole flash with the bootup logo.
I'm surprised it even flashes anything at all because in the wiki it talks about needing .bin files, but I used the .dfu file.

@River-Mochi
Copy link
Contributor

River-Mochi commented Feb 15, 2023

I was wondering how to upload a bootup logo to the pinecil v2.

Only the older original pinecil V1 models can use boot logo art for now since it uses DFU to do firmware updates and has a different MCU chip which accepts dfu image files.

The newer V2 has a BL706 MCU chip which takes "bin" files. The method to update the firmware can not use the same dfu flashers or dfu images from the past.

new Blisp flasher developed for the Pinecil V2 updating can not yet do boot logo art. For now Blisp can install IronOS firmware. Keep an eye for updates in the future. It's a little more complicated because of the way the BL706 is set up. I see that Ralim is working on this from an IronOS ticket.

@wbokslag
Copy link

I didn't feel like working around the limitations of the Blisp flashing tool, but got the bootup logo to work with relatively little effort. I did the following:

  • Modify img2logo.py in the IronOS-Meta repo to output the image data to a bin file (starts with 0xAA, defined as DATA_PROGRAMMED_MARKER in the python source.
  • Convert this image data to a char array, put this in BootLogo.cpp
  • alter handleShowingLogo(const uint8_t *ptrLogoArea) and forcibly set ptrLogoArea to point to your char array

Advantage is that this uses the regular boot logo format, although the image is now embedded in the cpp sources. Thought I'd share. You should be able to figure it out, if not, let me know 👍

@River-Mochi
Copy link
Contributor

River-Mochi commented Apr 12, 2023

@wbokslag thank you for making this temporary work-around until ralim changes blisp for all.

are you able to write out a few more steps - some people this might be their first time doing something like this. since it's changing the source code and then you are flashing a modified pinecilv2.bin?

@wbokslag
Copy link

Of course. Here goes:

Overview

This post is intended as a workaround for getting a boot logo to work on a pinecil v2, as long as the blisp flashing tool does not support it. In this post, I'll go through all the steps to do the following:

  • Get blisp, the flashing tool
  • Convert an image to the required format by altering img2logo.py from this repo
  • Alter the IronOS source code to load the converted image
  • Flashing the custom firmware with boot image to the pinecil v2

Linux only, but you can certainly do it on windows too

Getting blisp

You can get blisp in this repo: https://github.com/pine64/blisp. For me, the precompiled version did not work. As soon as I ran it, even without parameters, it complains about a wrong GLIBC version and exits. I thus pulled the sources, and followed the instructions in the readme. I ended up with blisp compiled. Keep this file, or copy it to /usr/local/bin/blisp to make it available system-wide

Converting your image

  • Check out this repo (IronOS-Meta)
  • Go to the Bootup Logos folder and add the following to a new file patch.file. The patch will make sure img2logo.py outputs another file (ends with .bin) that is the raw encoded image format, which is needed for our use
diff a/img2logo.py b/img2logo.py
index cdcaea3..083c253 100755
--- a/img2logo.py
+++ b/img2logo.py
@@ -232,6 +232,7 @@ def img2hex(
             data.extend(get_screen_blob([0] * LCD_NUM_BYTES, image_bytes))

     # Pad up to the full page size
+    size_without_padding = len(data)
     if len(data) < LCD_PAGE_SIZE:
         pad = [0] * (LCD_PAGE_SIZE - len(data))
         data.extend(pad)
@@ -249,6 +250,15 @@ def img2hex(
         split_name = [base,ext]
     output_name = output_filename_base +split_name[0] +split_name[1]

+    # Write raw binary data to bin file
+    fh = open(output_name + ".bin", 'wb')
+    bs = rb""
+    for byte in data:
+        bs += byte.to_bytes(1, 'big')
+    fh.write(bs[:size_without_padding])
+    fh.close()
+
+    # Write DFU file
     DFUOutput.writeFile(
         output_name + ".dfu",
         data,
  • Apply the patch with patch < patch.file
  • Now run the image conversion script for your image. We take IronOS.png as an example

./img2logo.py --pinecil Images/IronOS.png converted

  • Convert the bytes to c-code using xxd: xxd -i convertedIronOS.png.bin
  • Check the char array start with 0xAA.

Building IronOS

  • Pull the IronOS repo, follow the instructions and ensure you can build the pinecilv2 firmware
    • I encountered an issue with the docker-compose file not working on my setup. Removing the name field from the docker-compose.yml helped.
  • Apply the following patch to the BootLogo.cpp file as done previously. The patch overrides the usual image selection to use a statically defined one from the firmware image.
diff a/BootLogo.cpp b//BootLogo.cpp
index f21b8993..46f43f4e 100644
--- a/BootLogo.cpp
+++ b/BootLogo.cpp
@@ -13,7 +13,15 @@ void delay() {
   }
 }
 
+static unsigned char bootlogo[] = {
+  0xaa, 0x00, 0xff, ..... // image data here
+};
+
 void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) {
+
+  // Override usual logo ptr with our hardcoded one
+  ptrLogoArea = bootlogo;
+
   // Read the first few bytes and figure out what format we are looking at
   if (OLD_LOGO_HEADER_VALUE == *(reinterpret_cast<const uint32_t *>(ptrLogoArea))) {
     showOldFormat(ptrLogoArea);
  • Open the BootLogo.cpp file and add the image data inside the bootlogo character array.
  • Build the firmware again

Flashing

  • Assuming you have blisp, put soldering iron into flashing mode: press and hold minus button, insert power cable, hold minus button for 10 seconds, release. Screen should stay black
  • Flash with .\blisp.exe write --chip=bl70x --reset ./ci/artefacts/your_firmware.bin
  • That should be it!

@wbokslag
Copy link

Sure!

As far as I know, the Pinecil V2 cannot be bricked, as the bootloader can always be used to recover/reflash the firmware. Any bugs in the implementation can thus simply be reverted and/or a precompiled firmware may be flashed without issue. As far as I know, thus, don't shoot me if you do manage to brick it beyond repair :-)

Firmware updates can be pulled using git pull and as long as the BootLogo.cpp file did not contain changes really close to our addition, should work fine after recompilation and flashing. The requested pic is below

photo1681644657

Happy to help,

Wouter

@River-Mochi
Copy link
Contributor

River-Mochi commented Apr 18, 2023

@wbokslag some people probably feinted when they saw detailed instructions to make a custom fw for this 😲

@PowerWiesel
Copy link

PowerWiesel commented Apr 20, 2023

Here's a build of 2.21 with the animated IronOS bootlogo. Have fun 😃

If 2.21 gives you a black screen when you power up the pinecil, you can disable bluetooth as a temporary workaround.
Either just repower it until you get a screen or hold + and repower it until you get the debug screen and press - to get to the main screen. (it felt like you get a screen faster with the + method to me).
Then disable bluetooth in Advanced> bluetooth

Big thanks to @wbokslag for his guide ❤️

2_21-animated.zip

@River-Mochi
Copy link
Contributor

River-Mochi commented Apr 21, 2023

I made a video showing how to Install this specific "animated IRONOS logo" from the Zip file above that @PowerWiesel compiled and attached.
anyone can easily use the IronOS animated boot logo art without compiling the firmware or doing any scary github code changes. unfortunately if you want something else, you have to follow instructions way above and try to do it yourself or bribe someone to make alternative for you.

🎞️ https://youtu.be/LksT2AVOJsI

  • PineFlash app (easy premade binaries with widows/Linux). For macOS, it's not too bad, just a 1-step script to build it from binary from code. Blisp from command line can also be used instead of PineFlash.
  • On pinecil, go to User Interface > boot logo and set it to 4s or Infinity ♾️
  • Zip file above from PowerWeasel is custom firmware that has both the 2.21 update & boot Art at same time.

Note: some people reported issues with newest 2.21. this may be related to bluetooth on it. If your screen is black, keep rebooting and press buttons, screen eventually appeared for people at which point, go to Advanced and turn off Bluetooth fixes it. Otherwise roll back to 2.20. Ralim is investigating the issue.


IronOS

@RyanHakurei
Copy link

@PowerWiesel What are the upper limits to an animated bootlogo? How many frames are able to be included?

@PowerWiesel
Copy link

@PowerWiesel What are the upper limits to an animated bootlogo? How many frames are able to be included?

I can't give you a real answer, but I can tell you that the IronOS animation got 20 frames and give you the link to the animation pull request

Just try to convert the gif and you will see if it works

@wbokslag
Copy link

wbokslag commented Apr 26, 2023

@PowerWiesel What are the upper limits to an animated bootlogo? How many frames are able to be included?

If I understand correctly, the frames are not stored entirely. Basically, there is a 1KB area reserved for the boot logo or animation. After the initial image, a "delta" is specified per frame, telling how the next frame differs from the previous. As such, you can have many frames if they resemble a lot, or only a few if they contain large changes between frames.

However, when using my 'workaround', the logo data is stored in the code, and is no longer bound to this 1kb limitation. I'm sure you can fit in a larger animation, but you might need to make some adjustments to the gif-to-bootanim script and/or the bootlogo display code for the pinecil. Shouldn't be too hard if you have any experience with this sort of thing.

@Ralim
Copy link
Owner

Ralim commented Apr 27, 2023

Yep this is correct, the logo frames are either delta encoded or encoded as a whole frame (whatever is smaller for that frame).

Best advice is to try it and see, logos with largely static content with smaller animations will work better.

@oe9fwv
Copy link

oe9fwv commented Oct 17, 2023

for me this commandline
https://github.com/Ralim/IronOS-Meta#generating-the-logo-files
did not work:

"Go back to Powershell and type this command (change infile.png to the name of your image):

python img2logo.py infile.png out -m for Miniware
python img2logo.py infile.png out -p for Pinecil"

There is another description here:
https://github.com/Ralim/IronOS/blob/dev/Documentation/Logo.md

This commandline did the job for me. Maybe someone can look into this, I think it should be corrected.
thank you,

@Ralim
Copy link
Owner

Ralim commented Oct 18, 2023

Ah thats my bad, Ill remove the out of date instructions in the readme here.

@Ralim Ralim closed this as completed Oct 18, 2023
@SaucinYaMom
Copy link

Here's a build of 2.21 with the animated IronOS bootlogo. Have fun 😃

If 2.21 gives you a black screen when you power up the pinecil, you can disable bluetooth as a temporary workaround.
Either just repower it until you get a screen or hold + and repower it until you get the debug screen and press - to get to the main screen. (it felt like you get a screen faster with the + method to me).
Then disable bluetooth in Advanced> bluetooth

Big thanks to @wbokslag for his guide ❤️

2_21-animated.zip

Any chance you can make one for 2.22?

@Ralim
Copy link
Owner

Ralim commented Jan 5, 2024

Currently 2.22 is believed to fix the Bluetooth boot issues.
What would be the use case?

@SaucinYaMom
Copy link

I don't have the skills or time at the moment to compile a 2.22 version that includes the boot logo and I'd like to stay on the newest version with the boot logo but it's definitely not necessary

@discip
Copy link
Collaborator

discip commented Jan 6, 2024

If I'm not mistaken, you just need to do this:

Ralim/IronOS#1863 (comment)

@Ralim
Copy link
Owner

Ralim commented Jan 6, 2024

Once the logo is flashed in the correct location it will survive upgrades as well :)

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

9 participants