Skip to content

Instantly share code, notes, and snippets.

View orangecms's full-sized avatar
🐢
Hack the planet!

Daniel Maslowski orangecms

🐢
Hack the planet!
View GitHub Profile
@orangecms
orangecms / minilb.config
Created July 18, 2022 08:22
LinuxBoot mini config as a starting point
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="xinitcpud.cpio.xz"
# CONFIG_PERF_EVENTS_AMD_UNCORE is not set
CONFIG_EFI=y
CONFIG_KEXEC=y
CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="noefi ip=dhcp earlyprintk=ttyS0,115200,keep console=ttyS0,115200"
CONFIG_CMDLINE_OVERRIDE=y
# CONFIG_ACPI_PRMT is not set
CONFIG_NET=y
@orangecms
orangecms / dongshanpi-nezha-stu-stock-firmware-boot.log
Created July 3, 2022 15:58
DongshanPi Nezha STU stock firmware boot log (NAND flash)
[52]HELLO! BOOT0 is starting!
[55]BOOT0 commit : 9d92598
[58]set pll start
[60]periph0 has been enabled
[62]set pll end
[64][pmu]: bus read error
[66]board init ok
[68]DRAM only have internal ZQ!!
[71]get_pmu_exist() = -1
[73]DRAM BOOT DRIVE INFO: V0.32
@orangecms
orangecms / lichee-rv-pro-stock-boot.log
Created July 3, 2022 13:46
log of a stock firmware image booting on the Sipeed Lichee RV Dock Pro
[34]HELLO! BOOT0 is starting![Sep 18 2021, 11:27:51]
[39]BOOT0 commit : 3b45046
[42]set pll start
[44]periph0 has been enabled
[47]set pll end
[48][pmu]: bus read error
[50]board init ok
[52]enable_jtag
[54]DRAM only have internal ZQ!!
[57]get_pmu_exist() = -1
@orangecms
orangecms / useful.md
Created April 30, 2022 02:10
JavaScript for hardware shenanigans

Print register mask, little endian

(0xff0fffff).toString(2).split('').forEach((e,i) => console.info(`${31-i}:${e}`));
@orangecms
orangecms / rvdis
Created April 17, 2022 00:15
disassamble a few stupid single RISC-V instructions from 0x12345678 whatever
#!/bin/sh
_TMP=`mktemp`
echo -n $(rax2 -s "$1") > $_TMP
riscv64-linux-gnu-objdump -m riscv -b binary -D $_TMP | tail -n 5
rm $_TMP
@orangecms
orangecms / abstract.md
Last active March 28, 2022 18:51
Speedy Distro Porting via the cpu Command

Speedy Distro Porting via the cpu Command

Last year, I ported oreboot to the Allwinner D1 SoC that is found on the Nezha SBC and many other boards now. For a boot loader environment, I chose to embed LinuxBoot, and then partitioned an SD card with two root filesystems for testing: OpenWrt, which is small and just ran right away, and openSUSE, which required some extra effort. I was happy to see a new D1 board advertised with openSUSE support, though the process of getting there was tedious enough that I wanted to find an

#!/bin/sh
_REGS=`echo RomProtect{0,1,2,3} SPICntrl0 SPIRestrictedCmd{,2} AltSPICS`
for r in $_REGS; do
chipsec_util.py reg read $r
done
dmidecode -t bios -t system
@orangecms
orangecms / abstract.md
Created January 14, 2022 23:29
Drivers From Outer Space - Fast, Simple Driver Development

During the last two years, I have collected ARM and RISC-V gadgets and development boards. What I realized is that many of them run systems far off mainline Linux, and quite often do the vendors not publish the sources. However, when able to get serial output, I can fix that. And that is where many engineers start with regular development, so we are in the same boat.

Now how do the original drivers work? Applications in existing products often have userspace or hybrid drivers, which opens up a door. We can emulate the app, e.g., in QEMU, and monitor I/O accesses. Then we can write our own driver. But that is a tedious and time consuming process, the most inconvenient step being

@orangecms
orangecms / build-u-root.sh
Last active January 1, 2023 13:41
try oreboot on Allwinner D1 (Nezha and Lichee RV)
#!/bin/sh
set -e
_NAME=u-root-nezha
_DIR=/tmp/$_NAME
_FLAGS=-build=bb
# Get u-root, module workaround is necessary as of now
# see also https://github.com/u-root/u-root#warning-go-modules-are-a-work-in-progress-warning