Author: acassis

After installing Ubuntu 9.04 setup your terminal

After Ubuntu installation a real developer needs to setup the terminal:

Terminal -> Preferences

Click on “Unnamed” profile and select:

Custom font: Ubuntu Mono Regular size 15

Click on “Colors” tab, disable the “Use colors from system theme” and select:

“Green on black”

Click on “Scrolling” tab disable “Limit scrollback to:”

Close and you are done.

If you want other good font to use on Linux terminal:

$ sudo apt-get install fonts-inconsolata

I got the Inconsolata font suggestion from this site (its fonts packages are outdated) http://www.webupd8.org/2010/07/7-of-best-ubuntu-terminal-fixed-width.html

Compiling the NuttX RTOS for PROTECTED mode

Some microcontrollers like ARM Cortex-M4 has a Memory Protection Unit – MPU (not to be confused with Math Processing Unit) that can be used to create protected regions. This way an application cannot access the area where the NuttX kernel is located.

These are the steps to get the NuttX running in Protected Mode on STM32F4Discovery board:

$ ./tools/configure.sh stm32f4discovery:nsh

Build Setup —>
Build Host Platform (Windows) —> Linux

System Type —>
[*] MPU support

Build Setup —>
Build Configuration —>
Memory organization = NuttX protected build

Build Setup —>
Build Configuration —>
Pass one build directory = boards/arm/stm32/stm32f4discovery/kernel

Build Setup —>
Build Configuration —>
Beginning of user-space blob = 0x08020000

RTOS Features —>
-*- System call support —>
Number of reserved system calls = 8

$ make

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase nuttx.bin 0x08000000”

$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase nuttx_user.bin 0x08020000”

How to recover your data from Android when your LCD screen damage

Few days ago my Moto Z Play fell to the floor and the LCD screen became black. I couldn’t see the screen anymore.

Unfortunately when I plug my phone over USB cable to computer, nothing appears. It is because Android wait for user to select what USB function it needs to use (MTP, ADB, etc). Because I can’t see the screen it is not possible to select any option.

Searching in the internet for some tips how to solve this issue I found a nice tip from Olivia Henry: https://www.youtube.com/watch?v=tAChemeSbgo

Again I cannot use her suggestion because ADB is not enabled when I plug the cable to computer.

Then I remembered that I have an antitheft software called Cerberus installed on my phone. I just when to https://www.cerberusapp.com/dashboard and did the login in the system.

I selected the “Start Shell” and pressed Volume Down + Power button on the phone and listened the “take pictures” click sound.

Let see if we got some donuts:

$ cd /sdcard/Pictures/Screenshots

u0_a138@addison:/sdcard/Pictures/Screenshots $

u0_a138@addison:/sdcard/Pictures/Screenshots $ ls

Screenshot_20190724-142918.png

u0_a138@addison:/sdcard/Pictures/Screenshots $ mv Scree* screen.png

u0_a138@addison:/sdcard/Pictures/Screenshots $ ls

screen.png

u0_a138@addison:/sdcard/Pictures/Screenshots $ od -t x1 -v screen.png > screen.txt

u0_a138@addison:/sdcard/Pictures/Screenshots $ cat screen.txt

0000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52
0000020 00 00 04 38 00 00 07 80 08 02 00 00 00 a4 03 70
0000040 5d 00 00 00 03 73 42 49 54 08 08 08 db e1 4f e0

Then I selected all the text starting from “0000000 89…” until the last line at bottom, copied and paste it on text editor on computer and saved it as screenshot.txt.

Because I don’t want offset at beginning of each line, I removed it:

$ sed -i ‘s/^(.){8}//g’ screenshot.txt

And finally converted the text bytes to binary using this command:

$ for i in $(cat screenshot.txt) ; do printf “\x$i” ; done > screen.png

So using this trick I could access my phone again to backup some important files.

Getting the Serial Port working on WINE 4.0

I already used serial port on windows program running on Linux using wine: https://acassis.wordpress.com/2014/10/05/how-to-install-x-ctu-on-linux-using-wine/

But unfortunately the symbolic link ~/.wine/dosdevices/com1 pointing to /dev/ttyUSB0 was not working.

After spending some hours trying to fix this issue I found the solution! I need to run “wine regedit” and create a string entry named “COM1” with the value “/dev/ttyUSB0” inside HKEY_LOCAL_MACHINE\Software\Wine\Ports.

I found this solution thanks to this post: https://www.scivision.dev/wine-serial-port-links/

Running Chronometer demo on STM32LDiscover

Enter inside your NuttX Workspace, i.e.:

$ cd nuttxspace/

Enter inside /nuttx and update it:

$ cd nuttx/
$ git pull

Go to /apps directory and update it:

$ cd ../apps/
$ git pull

Return to /nuttx and clear the repository:
$ cd –
$ make distclean

Configure the stm32ldiscovery to use the chrono board profile:

$ ./tools/configure.sh stm32ldiscovery/chrono
Copy files
Refreshing…

Compile it:

$ make

Flash the Firmware:

$ openocd -f interface/stlink.cfg -f target/stm32l1.cfg -c init -c “reset halt” -c “flash write_image erase nuttx.bin 0x08000000”

Open other terminal and execute:

$ ./tools/ocdconsole.py

Return to previous terminal and execute:

$ openocd -f interface/stlink.cfg -f target/stm32l1.cfg

You should see the NuttX Shell starting in the other terminal:

$ ./tools/ocdconsole.py
==Link Activated

NuttShell (NSH)
nsh>

Just type “help” or “?” to see if chrono app is there if so run it:

nsh> ?
help usage: help [-v] []

? echo exit hexdump ls mh sleep xd
cat exec help kill mb mw usleep

Builtin Apps:
chrono slcd
nsh> chrono
Opening /dev/slcd0 for read/write access
Attributes:
rows: 1 columns: 6 nbars: 4
max contrast: 7 max brightness: 0
button_daemon: Running
button_daemon: Opening /dev/buttons
button_daemon: Supported BUTTONs 0x01