Verified Commit f3c37743 authored by Michal Hrusecky's avatar Michal Hrusecky 🦎

uboot-turris-omnia: Little cleanup & x86 tools

Cleaned up u-boot recipe a little bit and then messed it up again with x86 tools.
parent 30283553
......@@ -94,5 +94,7 @@ elif [ "$TARGET_BOARD" = omnia ]; then
mv ./logs ./logs-initram
cp build_dir/target-arm_*/linux-mvebu/zImage-initramfs-armada-385-turris-omnia bin/mvebu-musl/omnia-initramfs-zimage
mv build_dir/uboot* bin/mvebu-musl
mkdir -p bin/mvebu-musl/x86-64
cp build_dir/host/uboot-turris-omnia*/turris-omnia-uboot/* bin/mvebu-musl/x86-64
mv bin bin-nor
fi
......@@ -23,6 +23,7 @@ PKG_LICENSE_FILES:=Licenses/README
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/host-build.mk
define Package/uboot-turris-omnia
TITLE:=U-Boot for Turris Omnia
......@@ -42,19 +43,23 @@ define Build/Configure
endef
define Build/Compile
ls $(BUILD_DIR)
$(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) DTC=$(LINUX_DIR)/scripts/dtc/dtc
cp $(PKG_BUILD_DIR)/u-boot-spl.kwb $(PKG_BUILD_DIR)/uboot-turris-omnia-spl.kwb
echo "MVEBU_BOOTROM_UARTBOOT=y" >> $(PKG_BUILD_DIR)/.config
sed -i 's|.*\(CONFIG_MVEBU_BOOTROM_UARTBOOT\).*|\1=y|' $(PKG_BUILD_DIR)/.config
sed -i 's|spi|uart|' $(PKG_BUILD_DIR)/board/Marvell/db-88f6820-gp/kwbimage.cfg
$(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) DTC=$(LINUX_DIR)/scripts/dtc/dtc
cp $(PKG_BUILD_DIR)/u-boot-spl.kwb $(PKG_BUILD_DIR)/uboot-turris-omnia-uart-spl.kwb
mkdir -p $(HOST_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
$(HOSTCC) $(HOST_CFLAGS) -static -o $(HOST_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/kwboot $(PKG_BUILD_DIR)/tools/kwboot.c
$(HOSTCC) $(HOST_CFLAGS) -static -o $(HOST_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/sendbeacon ./files/sendbeacon.c
endef
define Package/uboot-turris-omnia/install
$(INSTALL_DIR) $(1)/boot/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uboot-turris-omnia-spl.kwb $(1)/boot/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uboot-turris-omnia-uart-spl.kwb $(1)/boot/
$(INSTALL_BIN) $(HOST_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/kwboot $(HOST_INSTALL_DIR)
$(INSTALL_BIN) $(HOST_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)/sendbeacon $(HOST_INSTALL_DIR)
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
/*
This program sends "beacon" to stop boot of Marvell Armada 385
so it waits for kwboot to load up U-Boot.
Copyright (C) 2016 CZ.NIC
Procedure:
1) Connect the serial line to the router
2) Run the program.
3) Power up the router within 5 sec.
4) Wait for the program to finish and run kwboot ... to load up U-Boot.
*/
#include <errno.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#define error_message(args...) fprintf(stderr, args)
int set_interface_attribs(int fd, int speed, int parity)
{
struct termios tty;
memset(&tty, 0, sizeof tty);
if(tcgetattr(fd, &tty) != 0) {
error_message("error %d from tcgetattr", errno);
return -1;
}
cfsetospeed(&tty, speed);
cfsetispeed(&tty, speed);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
tty.c_lflag = 0;
tty.c_oflag = 0;
tty.c_cc[VMIN] = 0;
tty.c_cc[VTIME] = 5;
tty.c_cflag |= (CLOCAL | CREAD);
tty.c_cflag &= ~(PARENB | PARODD);
tty.c_cflag |= parity;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
if(tcsetattr(fd, TCSANOW, &tty) != 0) {
error_message("error %d from tcsetattr", errno);
return -1;
}
return 0;
}
void set_blocking(int fd, int block)
{
struct termios tty;
memset(&tty, 0, sizeof tty);
if(tcgetattr(fd, &tty) != 0) {
error_message("error %d from tggetattr", errno);
return;
}
tty.c_cc[VMIN] = block ? 1 : 0;
tty.c_cc[VTIME] = 5;
if(tcsetattr(fd, TCSANOW, &tty) != 0)
error_message("error %d setting term attributes", errno);
}
void main(int argc, char** argv)
{
if(argc < 2) {
error_message("error: syntax %s <port>", argv[0]);
exit(1);
}
char *portname = argv[1];
int fd = open(portname, O_RDWR | O_NOCTTY | O_SYNC);
if(fd < 0) {
error_message("error %d opening %s: %s", errno, portname, strerror(errno));
return;
}
set_interface_attribs(fd, B115200, 0);
set_blocking(fd, 0);
printf("Sending beacon in loop. \
You have 5-10 seconds to power up Omnia.\n");
char buf [8]= {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xbb};
int i;
for(i=0;i<10000;i++)
write(fd, buf, 8);
close(fd);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment