shithub: p9-stm32-example-bare

Download patch

ref: 385ecf9c11ba7114801e877090951e1785698051
parent: 91f14160d425ce557a3fc589b9286fd82c56b7a8
author: kitzman <[email protected]>
date: Mon Nov 27 02:24:52 EST 2023

vlong fmt; util.rc update

--- a/libkern/dofmt.c
+++ b/libkern/dofmt.c
@@ -387,10 +387,10 @@
 		return -1;
 	}
 	if(!(fl & FmtUnsigned)){
-//		if(isv && (vlong)vu < 0){
-//			vu = -(vlong)vu;
-//			neg = 1;
-//		}else
+		if(isv && (vlong)vu < 0){
+			vu = -(vlong)vu;
+			neg = 1;
+		}else
 		if(!isv && (long)u < 0){
 			u = -(long)u;
 			neg = 1;
@@ -398,7 +398,7 @@
 	}
 	p = buf + sizeof buf - 1;
 	n = 0;
-	/*
+
 	if(isv){
 		while(vu){
 			i = vu % base;
@@ -410,7 +410,7 @@
 			*p-- = conv[i];
 			n++;
 		}
-	}else{*/
+	}else{
 		while(u){
 			i = u % base;
 			u /= base;
@@ -421,7 +421,7 @@
 			*p-- = conv[i];
 			n++;
 		}
-	//}
+	}
 	if(n == 0){
 		*p-- = '0';
 		n = 1;
--- a/util.rc
+++ b/util.rc
@@ -1,7 +1,14 @@
 #!/bin/rc
 
-baudrate=19200
-kernel=kernel
+if(! test -f /env/baudrate)
+	baudrate=307200
+#	baudrate=230400
+#	baudrate=192000
+#	baudrate=153600
+if(! test -f /env/baudratec)
+	baudratec=19200
+if(! test -f /env/kernel)
+	kernel=kernel
 
 fn stm_info {
 	echo 'using flashdev' $flashdev 'with baud' $baudrate
@@ -16,7 +23,7 @@
 fn stm_flash {
 	echo 'using flashdev' $flashdev 'with baud' $baudrate
 	if(! ~ $flashdev '') {
-		cat $kernel | stm32up -d -D $flashdev -b $baudrate \
+		cat $kernel | stm32up -D $flashdev -b $baudrate \
 			flash 0x08000000 '0x'`{cat $kernel | xd | tail -n 1}
 	}
 	if not {
@@ -27,7 +34,7 @@
 fn stm_go {
 	echo 'using flashdev' $flashdev 'with baud' $baudrate
 	if(! ~ $flashdev '') {
-		stm32up -d -D $flashdev -b $baudrate go 0x08000000
+		stm32up -D $flashdev -b $baudrate go 0x08000000
 	}
 	if not {
 		echo '$flashdev or $baudrate not set'
@@ -37,9 +44,15 @@
 fn stm_wunp {
 	echo 'using flashdev' $flashdev 'with baud' $baudrate
 	if(! ~ $flashdev '') {
-		stm32up -d -D $flashdev -b $baudrate writeunp
+		stm32up -D $flashdev -b $baudrate writeunp
 	}
 	if not {
 		echo '$flashdev or $baudrate not set'
 	}
+}
+
+fn stm_con {
+	echo 'connecting to' $flashdev 'with b'^$baudratec
+	echo 'b'^$baudratec >$flashdev^'ctl'
+	con -C $flashdev
 }