From b0941d4d632883472e5e6b33a364ef5b18f5b61a Mon Sep 17 00:00:00 2001 From: Pavel Demin Date: Tue, 4 Jul 2023 22:56:51 +0200 Subject: [PATCH] use hw_rev for board identification --- alpine/apps/server/server.c | 13 +++++++++++-- alpine/etc/local.d/apps.start | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/alpine/apps/server/server.c b/alpine/apps/server/server.c index 417206856..500e3ed66 100644 --- a/alpine/apps/server/server.c +++ b/alpine/apps/server/server.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,7 @@ void detach(char *path) exit(0); } -int main() +int main(int argc, char *argv[]) { FILE *fp; int fd, id, i, j, top; @@ -30,6 +31,8 @@ int main() size_t size; char buffer[256]; char path[291]; + char *end; + long freq; volatile int *slcr; if((fd = open("/dev/mem", O_RDWR)) < 0) @@ -41,6 +44,12 @@ int main() slcr = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0xF8000000); id = (slcr[332] >> 12) & 0x1f; + freq = (argc == 2) ? strtol(argv[1], &end, 10) : -1; + if(errno != 0 || end == argv[1] || freq < 0) + { + freq = 125; + } + if(fgets(buffer, 256, stdin) == NULL) { fwrite(forbidden, 24, 1, stdout); @@ -92,7 +101,7 @@ int main() { memcpy(path + 21 + i - 4, "/start.sh", 10); detach(path); - if(top && id == 7) + if(top && id == 7 && freq == 122) { memcpy(path + 21 + i - 4, "/index_122_88.html", 19); } diff --git a/alpine/etc/local.d/apps.start b/alpine/etc/local.d/apps.start index 6e633133c..6e994594d 100755 --- a/alpine/etc/local.d/apps.start +++ b/alpine/etc/local.d/apps.start @@ -1,2 +1,3 @@ -tcpserver -H -l 0 0 80 /media/mmcblk0p1/apps/server/server & +freq=`fw_printenv -n hw_rev | awk -F _ '{print $2}' | awk -F - '{print $1}'` +tcpserver -H -l 0 0 80 /media/mmcblk0p1/apps/server/server $freq & /media/mmcblk0p1/start.sh &