<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Upload issue due to 2-line code]]></title><description><![CDATA[<p dir="auto">I can't upload code to my Pycom Fipy anymore because this is the code that is running:</p>
<pre><code>import pycom
import machine
import time
from network import LTE

print(&quot;ik ga slapen&quot;)
machine.deepsleep(40*1000) 
</code></pre>
<p dir="auto">when i try to upload code i get this reaction</p>
<pre><code>Uploading project (main folder)...
Safe booting device... (see settings for more info)
Safe boot failed, uploading anyway.
Uploading to /flash...
Upload failed.: timeout Please reboot your device manually.
</code></pre>
<p dir="auto">but if i reset manually the device goes immediately in deepsleep as i coded...</p>
<p dir="auto">so how can i upload other code to my Pycom?</p>
<p dir="auto">kind regards,</p>
]]></description><link>https://forum.pycom.io/topic/6980/upload-issue-due-to-2-line-code</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 01:31:19 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/6980.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Apr 2021 12:09:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Upload issue due to 2-line code on Sun, 02 Jul 2023 09:31:18 GMT]]></title><description><![CDATA[<p dir="auto">I can't upload code to my Pycom Fipy anymore because this is the code that is running:</p>
<pre><code>import pycom
import machine
import time
from network import LTE

print(&quot;ik ga slapen&quot;)
machine.deepsleep(40*1000) 
</code></pre>
<p dir="auto">when i try to upload code i get this reaction</p>
<pre><code>Uploading project (main folder)...
Safe booting device... (see settings for more info)
Safe boot failed, uploading anyway.
Uploading to /flash...
Upload failed.: timeout Please reboot your device manually.
</code></pre>
<p dir="auto">but if i reset manually the device goes immediately in deepsleep as i coded...</p>
<p dir="auto">so how can i upload other code to my Pycom?</p>
<p dir="auto">kind regards,</p>
]]></description><link>https://forum.pycom.io/post/37920</link><guid isPermaLink="true">https://forum.pycom.io/post/37920</guid><dc:creator><![CDATA[frederik Leys]]></dc:creator><pubDate>Sun, 02 Jul 2023 09:31:18 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Fri, 16 Apr 2021 12:16:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/8245">@frederik-Leys</a> Pull P12 up (connect to 3.3V) and push reset. Then, <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a> and <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> will not be executed.</p>
]]></description><link>https://forum.pycom.io/post/37921</link><guid isPermaLink="true">https://forum.pycom.io/post/37921</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Fri, 16 Apr 2021 12:16:42 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Fri, 23 Jun 2023 20:39:29 GMT]]></title><description><![CDATA[<p dir="auto">I have the same problem, but I'm not using deep sleep, I only am able to upload new code if I upload the firmware again, any ideas?</p>
]]></description><link>https://forum.pycom.io/post/41547</link><guid isPermaLink="true">https://forum.pycom.io/post/41547</guid><dc:creator><![CDATA[Elias  Tapia]]></dc:creator><pubDate>Fri, 23 Jun 2023 20:39:29 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Sat, 24 Jun 2023 06:00:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/8331">@Elias-Tapia</a> See the previous post:</p>
<blockquote>
<p dir="auto">Pull P12 up (connect to 3.3V) and push reset. Then, <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a> and <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> will not be executed.</p>
</blockquote>
]]></description><link>https://forum.pycom.io/post/41548</link><guid isPermaLink="true">https://forum.pycom.io/post/41548</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Sat, 24 Jun 2023 06:00:46 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Tue, 27 Jun 2023 06:35:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a> would this work with my pysense? I am using a pysense and a lopy4, the thing is that I have two issues when I upgrade my firmware:  with the pycom firmware update v1.17.0.b4-development, I am able to upload my code this works, I'm receiving the data on chirpstack  and influxdb. Now I want to update the new code but the first thing that appears is OSError: [Errno 17] EEXIST pycom then: Uploading project (main folder)...<br />
The safe booting device... (see settings for more info)<br />
Safe boot failed, uploading anyway.<br />
Uploading to /flash...<br />
Upload failed.: timeout Please reboot your device manually.<br />
So I have to upload again the firmware with the tool. That is my first issue.<br />
The second is that my node is only able to send over a day or two then it disconnects from my chirpstack and unless I disconnect the device and reconect tothe source again it would not send the data, this is the code of the pysense:</p>
<p dir="auto">code_text</p>
<pre><code>#!/usr/bin/env python
#
# Copyright (c) 2019, Pycom Limited.
#
# This software is licensed under the GNU GPL version 3 or any
# later version, with permitted additional terms. For more information
# see the Pycom Licence v1.0 document supplied with this file, or
# available at https://www.pycom.io/opensource/licensing
#

&quot;&quot;&quot;
    OTAA Node example  as per LoRaWAN AS923 regional specification
    - compatible with the LoPy Nano Gateway and all other LoraWAN gateways
    - tested works with a LoRaServer, shall works on TTN servers
&quot;&quot;&quot;

from network import LoRa
import socket
import binascii
import struct
import time
import pycom
from CayenneLPP import CayenneLPP

from pysense import Pysense
from LIS2HH12 import LIS2HH12
from SI7006A20 import SI7006A20
from LTR329ALS01 import LTR329ALS01
from MPL3115A2 import MPL3115A2, ALTITUDE, PRESSURE

py = Pysense()
si = SI7006A20(py)
lt = LTR329ALS01(py)
li = LIS2HH12(py)

# Disable heartbeat LED
pycom.heartbeat(False)

LORA_CHANNEL = 1
LORA_NODE_DR = 4

'''
    utility function to setup the lora channels
'''
def prepare_channels(lora, channel, data_rate):

    AS923_FREQUENCIES = [
        { &quot;chan&quot;: 1, &quot;fq&quot;: &quot;923200000&quot; },
        #{ &quot;chan&quot;: 2, &quot;fq&quot;: &quot;923400000&quot; },
        #{ &quot;chan&quot;: 3, &quot;fq&quot;: &quot;922200000&quot; },
        #{ &quot;chan&quot;: 4, &quot;fq&quot;: &quot;922400000&quot; },
        #{ &quot;chan&quot;: 5, &quot;fq&quot;: &quot;922600000&quot; },
        #{ &quot;chan&quot;: 6, &quot;fq&quot;: &quot;922800000&quot; },
        #{ &quot;chan&quot;: 7, &quot;fq&quot;: &quot;923000000&quot; },
        #{ &quot;chan&quot;: 8, &quot;fq&quot;: &quot;922000000&quot; },
    ]

    if not channel in range(0, 9):
        raise RuntimeError(&quot;channels should be in 1-8 for AS923&quot;)

    if channel == 0:
        import  uos
        channel = (struct.unpack('B',uos.urandom(1))[0] % 7) + 1

    for i in range(0, 8):
        lora.remove_channel(i)

    upstream = (item for item in AS923_FREQUENCIES if item[&quot;chan&quot;] == channel).__next__()

    # set default channels frequency
    lora.add_channel(int(upstream.get('chan')), frequency=int(upstream.get('fq')), dr_min=0, dr_max=data_rate)

    return lora

'''
    call back for handling RX packets
'''
def lora_cb(lora):
    events = lora.events()
    if events &amp; LoRa.RX_PACKET_EVENT:
        if lora_socket is not None:
            frame, port = lora_socket.recvfrom(512) # longuest frame is +-220
            print(port, frame)
    if events &amp; LoRa.TX_PACKET_EVENT:
        print(&quot;tx_time_on_air: {} ms @dr {}&quot;, lora.stats().tx_time_on_air, lora.stats().sftx)

'''
    Main operations: this is sample code for LoRaWAN on AS923
'''

lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AS923, device_class=LoRa.CLASS_A, adr=True)

# create an OTA authentication params
dev_eui = binascii.unhexlify('******')
app_eui = binascii.unhexlify('********')
#nwk_key = binascii.unhexlify('******')
app_key = binascii.unhexlify('********')


# join a network using OTAA
lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0, dr=2) # AS923 always joins at DR2
prepare_channels(lora, LORA_CHANNEL,  LORA_NODE_DR)

# wait until the module has joined the network
print('Over the air network activation ... ', end='')
while not lora.has_joined():
    time.sleep(2.5)
    print('.', end='')
print('OTAA joined')

# create a LoRa socket
lora_socket = socket.socket(socket.AF_LORA, socket.SOCK_RAW)

# set the LoRaWAN data rate
lora_socket.setsockopt(socket.SOL_LORA, socket.SO_DR, LORA_NODE_DR)

# msg are confirmed at the FMS level
lora_socket.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, 0)

# make the socket non blocking y default
lora_socket.setblocking(False)

lora.callback(trigger=( LoRa.RX_PACKET_EVENT |
                        LoRa.TX_PACKET_EVENT |
                        LoRa.TX_FAILED_EVENT  ), handler=lora_cb)

time.sleep(4) # this timer is important and caused me some trouble ...

for i in range(0, 100000000):
    #pkt = struct.pack('&gt;H', i)
    #print('Sending:', pkt)
    #lora_socket.send(pkt)
    #time.sleep(300)

    pycom.rgbled(0x000014)
    lpp = CayenneLPP()

    print('\n\n** Humidity and Temperature Sensor (SI7006A20)')
    print('Humidity', si.humidity())
    print('Temperature', si.temperature())
    lpp.add_relative_humidity(1, si.humidity())
    lpp.add_temperature(1, si.temperature())

    mpPress = MPL3115A2(py,mode=PRESSURE)
    print('\n\n** Barometric Pressure Sensor with Altimeter (MPL3115A2)')
    print('Pressure (hPa)', mpPress.pressure()/100)
    lpp.add_barometric_pressure(1, mpPress.pressure()/100)

    '''
    print('\n\n**LoRa stats')
    SNR=lora.stats().snr
    RSSI=lora.stats().rssi
    print(&quot;SNR: {}u @RSSI: {}&quot;.format(SNR, RSSI))
    lpp.add_snr(1, SNR)
    lpp.add_rssi(1, RSSI)
    '''


    encoded_payload = lpp.get_buffer()
    print('Sending data (uplink)...')
    lora_socket.send(bytes(encoded_payload))
    #lora_socket.setblocking(False)
    data = lora_socket.recv(64)
    #Payload
    payload_size = len(encoded_payload)
    print(&quot;Payload size:&quot;, payload_size, &quot;bytes&quot;)
    #Data
    print('Received data (downlink)', data)
    pycom.rgbled(0x001400)
    time.sleep(300)
</code></pre>
<p dir="auto"><strong>Any ideas?</strong></p>
]]></description><link>https://forum.pycom.io/post/41552</link><guid isPermaLink="true">https://forum.pycom.io/post/41552</guid><dc:creator><![CDATA[Elias  Tapia]]></dc:creator><pubDate>Tue, 27 Jun 2023 06:35:31 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Tue, 27 Jun 2023 06:37:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/8331">@Elias-Tapia</a> I uinderstand that you have issues to update the Python code. Which tool do you use to update the Python code?</p>
]]></description><link>https://forum.pycom.io/post/41553</link><guid isPermaLink="true">https://forum.pycom.io/post/41553</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Tue, 27 Jun 2023 06:37:46 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Wed, 28 Jun 2023 14:28:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a> I am using atom, with the pymakr plugin</p>
]]></description><link>https://forum.pycom.io/post/41555</link><guid isPermaLink="true">https://forum.pycom.io/post/41555</guid><dc:creator><![CDATA[Elias  Tapia]]></dc:creator><pubDate>Wed, 28 Jun 2023 14:28:42 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Thu, 29 Jun 2023 07:05:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/8331">@Elias-Tapia</a> Using Ctrl-C from a serial terminal you should be able to interrupt your code and get a REPL prompt, unless your code disables keyboard interrupt. For that situation pulling up P12 and pushing reset helps. It skips execution of <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a> and <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> and gets you to a REPL prompt. Then, you can change or replace <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> &amp; <a href="http://boot.py" target="_blank" rel="noopener noreferrer nofollow">boot.py</a>. All these low level operations are better done with  a simple serial terminal and NOT IDE's like pymakr or Thonny.<br />
It is good practice to put your main application not into <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a>, but in a file with e.g. the name my_app.py, and have <a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow">main.py</a> just be something like:</p>
<pre><code>import time
time.sleep(3)
import my_app
</code></pre>
<p dir="auto">That gives you a time slot of 3 seconds to interrupt the start process.</p>
<p dir="auto">I cannot tell you a lot about the disconnection problem. Things that happen only after days are hard to trace. Maybe it's a memory fragmentation problem. Then it might help to add <code>gc.collect()</code> to the main loop of your code.<br />
Note:<br />
Using P12 pull-up does NOT stop the hidden _boot.py and _main.py.</p>
]]></description><link>https://forum.pycom.io/post/41556</link><guid isPermaLink="true">https://forum.pycom.io/post/41556</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Thu, 29 Jun 2023 07:05:57 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Fri, 30 Jun 2023 20:50:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a> thanks a lot, it works on terminal,i'll implement gc.collect() then..<br />
One more thing  I have a LOPY4 unable to be udpated by pycom firmware udpater but this error came out: The upgrade failed due to the following error:<br />
Failed to connect to Espressif device: No serial data received.For<br />
troubleshooting steps visit: <a href="https://docs.espressif.com/projects/" target="_blank" rel="noopener noreferrer nofollow">https://docs.espressif.com/projects/</a><br />
esptool/en/latest/troubleshooting.html, but the link gives the error 404 page not found</p>
]]></description><link>https://forum.pycom.io/post/41557</link><guid isPermaLink="true">https://forum.pycom.io/post/41557</guid><dc:creator><![CDATA[Elias  Tapia]]></dc:creator><pubDate>Fri, 30 Jun 2023 20:50:52 GMT</pubDate></item><item><title><![CDATA[Reply to Upload issue due to 2-line code on Sat, 01 Jul 2023 06:13:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/8331">@Elias-Tapia</a> Assuming you have the LOPY4 attached to some kind of USB/Serial interface, like an expansion board, the Updater should always work. You can try to force the ESP32 into update mode by pulling P2 to GND an pushing Reset. You msut as well verify that you use the proper Serial port on your PC.</p>
]]></description><link>https://forum.pycom.io/post/41558</link><guid isPermaLink="true">https://forum.pycom.io/post/41558</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Sat, 01 Jul 2023 06:13:47 GMT</pubDate></item></channel></rss>