Skip to content

Instantly share code, notes, and snippets.

@pacmac
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacmac/3425f3070ce9652b0377 to your computer and use it in GitHub Desktop.
Save pacmac/3425f3070ce9652b0377 to your computer and use it in GitHub Desktop.
bblack_arch
#!/bin/sh
## install acpi
pacman -S acpid
echo "add poweroff > handler.sh"
nano /etc/acpi/handler.sh
systemctl enable acpid.service
systemctl start acpid.service
## install tools
echo "Install Tools"
pacman -Syu wget dosfstools
## sync time
echo "Install and Sync Date/Time"
pacman -S ntp
systemctl enable ntpd
systemctl start ntpd
## make filesystems
echo "Create Filesystems"
mkfs.vfat -F 16 /dev/mmcblk1p1
mkfs.ext4 /dev/mmcblk1p2
## get bootloader
echo "Install Bootloader"
if [ ! -f BeagleBone-bootloader.tar.gz ]; then
wget http://archlinuxarm.org/os/omap/BeagleBone-bootloader.tar.gz
fi
mkdir -p boot
mount /dev/mmcblk1p1 boot
tar -xvf BeagleBone-bootloader.tar.gz -C boot
umount boot
## Install system
echo "Install O/S"
if [ ! -f ArchLinuxARM-am33x-latest.tar.gz ]; then
wget http://archlinuxarm.org/os/ArchLinuxARM-am33x-latest.tar.gz
fi
mkdir -p root
mount /dev/mmcblk1p2 root
tar -xzvf ArchLinuxARM-am33x-latest.tar.gz -C root
cp -rp packages.sh root/root
## Finish Up
umount root
echo "@@@@ Done @@@@"
#!/bin/sh
SD="/dev/sdb"
## format SD card
echo "Creating Partitions on "$SD
export device=$SD
echo "o
p
n
p
1
+64M
t
e
a
n
p
2
w" | fdisk $device
sleep 2
## Create SD File Systems
echo "Make Filesystems..."
mkfs.vfat -F 16 $SD"1"
mkfs.ext4 $SD"2"
## get bootloader
echo "Install Bootloader..."
wget http://archlinuxarm.org/os/omap/BeagleBone-bootloader.tar.gz
mkdir -p boot
mount $SD"1" boot
tar -xvf BeagleBone-bootloader.tar.gz -C boot
umount boot
## Install system
echo "Install O/S..."
wget http://archlinuxarm.org/os/ArchLinuxARM-am33x-latest.tar.gz
mkdir -p root
mount $SD"2" root
tar -xzvf ArchLinuxARM-am33x-latest.tar.gz -C root
## Copy Source Files
echo "Copying Source Files..."
cp -rp BeagleBone-bootloader.tar.gz root/root
cp -rp ArchLinuxARM-am33x-latest.tar.gz root/root
cp -rp emmc_install.sh root/root
cp -rp packages.sh root/root
## Finish up
umount root
echo "@@@@ Done @@@@"
# /etc/systemd/system/boot.service
# systemctl enable boot.service
#
[Unit]
Description = FBTFT
DefaultDependencies=no
After=local-fs.target
Before=base.target
[Service]
ExecStart=/bin/sh /usr/share/scripts/sh/boot.sh
RemainAfterExit=yes
[Install]
WantedBy=getty.target
#!/bin/sh
# /usr/share/scripts/sh/boot.sh
/usr/bin/echo HY28A | sudo tee /sys/devices/bone_capemgr.*/slots;
/usr/bin/modprobe fbtft_device name=hy28a busnum=1 gpios=reset:48 rotate=270
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation. *
dtc -O dtb -o HY28A-00A0.dtbo -b 0 -@ HY28A-00A0.dts
cp HY28A-00A0.dtbo /lib/firmware/
echo HY28A > /sys/devices/bone_capemgr.9/slots *
modprobe fbtft_device name=hy28a busnum=1 gpios=reset:48 rotate=270
XXX: capemgr.enable_partno=BB-SPI1 should not be set in uEnv.txt since it
conflicts with P9.31
PinReg: PIN.5:Receive, PIN.4:Pull-Up/Down, 3:PUD Enable, PIN.2.1.0: Mode
*/
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "HY28A";
version = "00A0";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P9.31", /* spi1_sclk */
// "P9.29", /* spi1_d0 */
"P9.30", /* spi1_d1 */
"P9.28", /* spi1_cs0 */
"// P9.42", /* spi1_cs1 */
"P9.15", /* gpio1_16 - reset */
"P9.23", /* gpio1_17 - led */
"P9.12", /* gpio1_28 - dc */
/* the hardware ip uses */
"spi1",
"gpio1_16",
"gpio1_17",
"gpio1_28";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
/* default state has all gpios released and mode set to uart1 */
bb_spi1_pins: pinmux_bb_spi1_pins {
pinctrl-single,pins = <
0x190 0x33 /* 51 - mcasp0_aclkx.spi1_sclk, INPUT_PULLUP | MODE3 */
0x194 0x33 /* 51 - mcasp0_fsx.spi1_d0, INPUT_PULLUP | MODE3 */
0x198 0x13 /* 19 - mcasp0_axr0.spi1_d1, OUTPUT_PULLUP | MODE3 */
0x19c 0x13 /* 19 - mcasp0_ahclkr.spi1_cs0, OUTPUT_PULLUP | MODE3 */
//0x164 0x12 /* 18 - eCAP0_in_PWM0_out.spi1_cs1 OUTPUT_PULLUP | MODE2 */
>;
};
};
};
fragment@1 {
target = <&spi1>; /* spi1 is numbered correctly */
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_spi1_pins>;
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <0>;
spi-max-frequency = <32000000>;
spi-cpha;
};
channel@1 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <1>;
spi-max-frequency = <32000000>;
};
};
};
fragment@2 {
target = <&am33xx_pinmux>;
__overlay__ {
status = "okay";
lcd_ctrl_pinmux: lcd_ctrl_pins {
pinctrl-single,pins = <
0x040 0x17 /* 23 - RESET gpio1_16 OUTPUT_PULLUP | MODE7 */
0x044 0x0F /* 15 - LED gpio1_17 OUTPUT_PULDOWN | MODE7 */
0x078 0x17 /* 23 - DC gpio1_28 OUTPUT_PULLUP | MODE7 */
>;
};
};
};
fragment@3 {
target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&lcd_ctrl_pinmux>;
status = "okay";
};
};
};
};
#!/bin/sh
## install acpi
pacman -S acpid
echo "add poweroff > handler.sh"
nano /etc/acpi/handler.sh
systemctl enable acpid.service
systemctl start acpid.service
## install tools
echo "Install Tools"
pacman -Syu wget dosfstools git base-devel
## sync time
echo "Install and Sync Date/Time"
pacman -S ntp
systemctl enable ntpd
systemctl start ntpd
## python
pacman -S python2
#!/bin/sh
##Disable HDMI
mkdir /mnt/boot
mount /dev/mmcblk0p1 /mnt/boot
nano /mnt/boot/uEnv.txt
#> optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
umount /mnt/boot
reboot
## Test to see if disabled ( no L )
cat /sys/devices/bone_capemgr.*/slots
#> 0: 54:PF---
#> 1: 55:PF---
#> 2: 56:PF---
#> 3: 57:PF---
#> 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
#> 5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
#> 6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
## Check Dependancies
zgrep -E "CONFIG_SPI=|CONFIG_GPIOLIB=|DEFERRED|FB_SYS_|FB_BACKLIGHT" /proc/config.gz
#> CONFIG_SPI=y
#> CONFIG_GPIOLIB=y
#> CONFIG_FB_SYS_FILLRECT=y
#> CONFIG_FB_SYS_COPYAREA=y
#> CONFIG_FB_SYS_IMAGEBLIT=y
#> CONFIG_FB_SYS_FOPS=y
#> CONFIG_FB_DEFERRED_IO=y
## Kernel Headers
pacman -S linux-am33x-legacy linux-headers-am33x-legacy
## install FBTFT
git clone https://github.com/notro/fbtft
cd fbtft
make
sudo make install
depmod
# enable SPI & Test
echo BB-SPIDEV0 | sudo tee /sys/devices/bone_capemgr.*/slots
#> BB-SPIDEV0
ls -l /dev/spi*
#> crw-rw---T 1 root spi 153, 1 Jul 2 15:01 /dev/spidev1.0
#> crw-rw---T 1 root spi 153, 0 Jul 2 15:01 /dev/spidev1.1
sudo modprobe fbtft_device name=hy28b busnum=1 #gpios=reset:XX
dmesg | tail
## Touch Screen
git clone https://github.com/notro/fbtft_tools
cd fbtft_tools/ads7846_device/
make
make install
depmod
# example
modprobe ads7846_device busnum=1 gpio_pendown=117 x_plate_ohms=100 pressure_max=255
dmesg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment