shithub: p9-stm32-example-os

ref: f801657f77f3923ec2388c25bdcb036c8019ba89
dir: /util.rc/

View raw version
#!/bin/rc

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
	if(! ~ $flashdev '') {
		stm32up -d -D $flashdev -b $baudrate info
	}
	if not {
		echo '$flashdev or $baudrate not set'
	}
}

fn stm_flash {
	echo 'using flashdev' $flashdev 'with baud' $baudrate
	if(! ~ $flashdev '') {
		cat $kernel | stm32up -D $flashdev -b $baudrate \
			flash 0x08000000 '0x'`{cat $kernel | xd | tail -n 1}
	}
	if not {
		echo '$flashdev or $baudrate not set'
	}
}

fn stm_go {
	echo 'using flashdev' $flashdev 'with baud' $baudrate
	if(! ~ $flashdev '') {
		stm32up -D $flashdev -b $baudrate go 0x08000000
	}
	if not {
		echo '$flashdev or $baudrate not set'
	}
}

fn stm_wunp {
	echo 'using flashdev' $flashdev 'with baud' $baudrate
	if(! ~ $flashdev '') {
		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
}