# Recon Sentinel is Rock in a box.



## Phishfry (Jan 29, 2022)

Got my Rock64 in the mail today. eMMC and flasher left China too from Pine store.
This Recon Sentinel is a nice implementation. Box, manual, AC Cord. Retail package.
$40 new off ebay.








						Teardown: Recon Sentinel
					

It might be hard to imagine now, but there was a time when the average home had only a single Internet connected device in it. This beige box, known as a “desktop computer” in those old…




					hackaday.com
				




Flash uboot to SPI and FreeBSD to eMMC.

Figure out that LED!!!


----------



## Phishfry (Jan 29, 2022)

I started with the FreeBSD 14-CURRENT image.
This is a new build for me and it is nice to have it fire right up.
I fought the UART console on this board for a while.
Uses weird speed of 1500000 baud.
Several Prolific PL2303HX USB to TTL adapters I have must be fake.
They won't do 1500000.
Known real one works fine.
Dang even Prolific adapters are faked. I thought it was only FDTI.


----------



## Phishfry (Jan 29, 2022)

U-Boot has a tool for everything it seems.


```
=> sf
sf - SPI flash sub-system

Usage:
sf probe [[bus:]cs] [hz] [mode]    - init flash device on given SPI bus
                  and chip select
sf read addr offset|partition len    - read `len' bytes starting at
                          `offset' or from start of mtd
                      `partition'to memory at `addr'
sf write addr offset|partition len    - write `len' bytes from memory
                          at `addr' to flash at `offset'
                      or to start of mtd `partition'
sf erase offset|partition [+]len    - erase `len' bytes from `offset'
                      or from start of mtd `partition'
                     `+len' round up `len' to block size
sf update addr offset|partition len    - erase and write `len' bytes from memory
                      at `addr' to flash at `offset'
                      or to start of mtd `partition'
sf protect lock/unlock sector len    - protect/unprotect 'len' bytes starting
                      at address 'sector'
```
Now my SPI chip:

```
=> sf probe

SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
```


----------



## Andriy (Jan 29, 2022)

I have a couple of those Recon Sentinel Rock64-s since early 2021.
Wish I bought more of them when they were like $10 on Amazon.

They are pretty standard Rock64-s.
I run one with FreeBSD on eMMC and the other with SD card.
I wanted to try putting u-boot on SPI flash but couldn't find any information about its required layout.

BTW, the spi flash is accessible from FreeBSD too.


----------



## Phishfry (Jan 29, 2022)

10 bucks would have been a steal. Cheapest on ebay is $100.
One feature I like is the extra room in the case. I suspect I could fit a few small GPIO gadgets in there.

I do want to put u-boot on the SPI.

```
root@ROCK64:~ # ls /dev/flash
spi0
root@ROCK64:~ # ls /dev/flash/spi0
/dev/flash/spi0
root@ROCK64:~ # file -s /dev/flash/spi0
/dev/flash/spi0: ISO-8859 text, with very long lines (65536), with no line terminators
```

What I was really mentally juggling is "should I put EFI on SPI" as well. It is 128Mib so there is plenty of room.


----------



## Andriy (Jan 30, 2022)

Please share your progress!


----------



## Phishfry (Jan 30, 2022)

I strayed to the LED since I have never dealt with one before. 2x16 display.

`pkg install i2c-tools`

`root@ROCK64:~ # i2c -s
18`

So i2c may already be configured for us.
Connect LCD and rescan.

`root@ROCK64:/ # i2c -s
18 3f`
New device found at 3f. That is good.


----------



## Phishfry (Jan 30, 2022)

I went and imaged the spi0 device just in case.
`root@ROCK64:/ # dd if=/dev/flash/spi0 of=/spi.orig bs=1024 conv=sync status=progress
  16224256 bytes (16 MB, 15 MiB) transferred 10.003s, 1622 kB/s  
16384+0 records in
16384+0 records out`

Wanted to see what was on the disk. It appears empty.
`root@ROCK64:/ # hexdump spi.orig|more
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
1000000`


----------



## diizzy (Jan 30, 2022)

Phishfry 
Regarding your serial adapters... https://wiki.freebsd.org/USB/Peripherals/Serial


----------



## Phishfry (Jan 30, 2022)

I was hoping to send some command to see text  on the LCD. I made a text file with plain text to send.
Similar to the manual i2c write example.





						i2c
					






					www.freebsd.org
				




```
root@ROCK64:~ # i2c -a 0x3f -dw -c 16 -o 0x10-b < data.bin
root@ROCK64:~ # i2c -a 0x3f -d w -c 16 < data.bin
root@ROCK64:~ # i2c -a 0x3f -d w -c 16 -o 0x10 < data.bin
root@ROCK64:~ # i2c -a 0x3f -d w -c 16 -o 0x10 -b < data.bin
```

Please help me write text to i2c 2x16 sainsmart type LCD.

The only movment I have is changing the -c parameter. -c < 8 backlight off -c >= 8 on


----------



## covacat (Jan 30, 2022)

take a look at








						recon-sentinel-hacking/rslcd.py at main · jjg/recon-sentinel-hacking
					

Contribute to jjg/recon-sentinel-hacking development by creating an account on GitHub.




					github.com


----------



## Phishfry (Jan 31, 2022)

Bummer that sysutils/lcdproc is not available for aarch64.



			LCDproc User's Guide
		

*Example 5.3. HD44780: Configuration for I2C with port expander*


[HD44780]
ConnectionType=i2c
Device=/dev/i2c-0
Port=0x20
Backlight=yes
Size=40x2
DelayBus=false
DelayMult=1
Keypad=no


----------



## Andriy (Jan 31, 2022)

I have some home-made code that works via gpio interface: https://github.com/avg-I/gpiolcd
You'd also need pcf8574(4) driver (the link doesn't work as the driver is new, it's in main and stable/13).


----------



## Phishfry (Jan 31, 2022)

Thank You. I am somewhat illiterate and I am first going to try and force compile sysutils/lcdproc on aarch64.
It seems to me that it should absolutely run on arm64.
So I want to pester port maintainer once I figure out why its not building on aarch64.

For 3 years it appears? It don't have many dependencies at all.


			Lcdproc support for AARCH64 Pine64-LTS
		


Linux -libusb stuff is messed up I see but I don't need it here for my i2c serial comms.


----------



## Phishfry (Feb 21, 2022)

Andriy said:


> Please share your progress!


OK No EFI allowed on SPI only u-boot
There is documentation on the procedure.








						u-boot/README.rockchip at master · ARM-software/u-boot
					

Clone of upstream U-Boot repo with patches for Arm development boards - u-boot/README.rockchip at master · ARM-software/u-boot




					github.com
				



Line 219 to be exact.

Received 32GB eMMC and installed FreeBSD 13-RELEASE ROCK64.
Ran `freebsd-update` for the first time in my life it worked on ARM.
Fireworks are in order. Pop the corks. A new era.


----------



## Andriy (Feb 21, 2022)

Phishfry said:


> OK No EFI allowed on SPI only u-boot
> There is documentation on the procedure.
> 
> 
> ...


Did you need yo recompile u-boot for it to have SPI support?
Or is the u-boot from packages already good?
Thanks!


----------



## obsigna (Feb 21, 2022)

Phishfry said:


> I was hoping to send some command to see text  on the LCD. I made a text file with plain text to send.
> Similar to the manual i2c write example.
> 
> 
> ...


I followed the link of your initial post and on the 2nd image we see a HD44780 display with a PCF8547 I2C to DIO converter. This is a pretty common setup. For example here in Brazil this is offered for less than US$ 5 from many suppliers - https://lista.mercadolivre.com.br/16x2-display

Two years ago I bought the bigger brother of that display, here I have a 20x4, based on exactly the same chipset. At that time, I found this Arduino-C++ library on GitHub: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

I refactored it into a pure C library for my BeagleBone Black and FreeBSD 13, and I added I2C glue code and a Hello World test program to it (see the attached .zip file).

For your 16x2 display, you need to change the top 4 definitions in lcd.h, and in the test program, you need to shorten the text, then compile and execute it using: `clang i2c.c lcd.c hello.c -o hello && ./hello`


----------



## Phishfry (Feb 22, 2022)

Andriy said:


> is the u-boot from packages already good?


I am still unsure what files to flash to SPI.
The above instruction pre-date the Rockboard SPI commit by 5 years. They were wrote for Firefly board.

One difference I notice from other boards is that TPL is loaded before SPL on Rock64.
TPL being First stage bootloader.

```
U-Boot TPL 2020.10 (Apr 09 2021 - 03:54:54)
LPDDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.10 (Apr 09 2021 - 03:54:54 +0000)
Trying to boot from MMC1
Card did not respond to voltage select!
spl: mmc init failed with error: -95
Trying to boot from MMC2
NOTICE:  BL31: v2.4(release):
NOTICE:  BL31: Built : 03:54:01, Apr  9 2021
NOTICE:  BL31:Rockchip release version: v1.2


U-Boot 2020.10 (Apr 09 2021 - 03:56:02 +0000)

Model: Pine64 Rock64
DRAM:  1022 MiB
PMIC:  RK8050 (on=0x40, off=0x01)
MMC:   mmc@ff500000: 1, mmc@ff520000: 0
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: Pine64 Rock64
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0
```

So what is this BOOTROM ? Is this the SPI storage device?
Under u-boot port there is a TPL directory. So perhaps something there gets flashed to SPI.
u-boot-tpl.bin for example.

You would almost certainly need to build the rock64 u-boot port for the SPI file.
There are only two files that end up in /usr/local/share/u-boot/u-boot-rock64/
idbloader.img and u-boot.itb I am pretty sure they are for the sd card install.


----------



## SleepWalker (Mar 20, 2022)

To install this bootloader on an SPI flash just do:

=> load ${devtype} ${devnum} ${kernel_addr_r} u-boot-spi.bin
=> sf probe
=> sf update ${kernel_addr_r} 0 ${filesize}



			Index of /download/u-boot/u-boot-roc-rk3399-pc-plus/


----------



## BSDer (Apr 23, 2022)

SleepWalker, can you share how to make u-boot-spi.bin?

And would you see any inconvenience to dd it into /dev/flash/spi0?

Thank you.


----------



## SleepWalker (May 4, 2022)

BSDer said:


> SleepWalker, can you share how to make u-boot-spi.bin?
> 
> And would you see any inconvenience to dd it into /dev/flash/spi0?
> 
> Thank you.


My unofficial u-boot ports collection https://github.com/S199pWa1k9r/ports/tree/master/sysutils


----------



## ice051 (Dec 11, 2022)

Thanks obsigna.

My hardware is RPi 4B.

`uname -a`

```
FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n259495-d1f3abc89250: Thu Dec  1 10:53:21 UTC 2022     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64
```

I want to display text in 1602A.

I modified lcd.h and hello.c, compiled and ran, terminal prompt:

```
I2C I2CRDWR: Resource temporarily unavailable
I2C I2CRDWR: Resource temporarily unavailable
I2C I2CRDWR: Resource temporarily unavailable
I2C I2CRDWR: Resource temporarily unavailable
...
```

May I ask, how should I modify the program to make it run normally in RPi 4B?


----------

