Skip to content

Commit

Permalink
use hw_rev for board identification
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-demin committed Jul 4, 2023
1 parent ddfefe2 commit b0941d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions alpine/apps/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
Expand All @@ -22,14 +23,16 @@ void detach(char *path)
exit(0);
}

int main()
int main(int argc, char *argv[])
{
FILE *fp;
int fd, id, i, j, top;
struct stat sb;
size_t size;
char buffer[256];
char path[291];
char *end;
long freq;
volatile int *slcr;

if((fd = open("/dev/mem", O_RDWR)) < 0)
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion alpine/etc/local.d/apps.start
Original file line number Diff line number Diff line change
@@ -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 &

0 comments on commit b0941d4

Please sign in to comment.