Play video content EXCLUSIVE TMZ.com

Soulja Boy was just smacked with a sentence of 240 days in jail and 265 days of community service for violating his probation.

Soulja was in court Tuesday -- and while his attorney said the rapper's had an "awakening" during the last 20 days he's been locked up -- it clearly wasn't enough to convince the judge to let him go easy. Soulja will start the sentence right away ... and has credit for 40 days served.

The judge told Soulja he was originally considering sentencing him to 2 years in state prison but decided to give him some leniency. The judge also acknowledged that Soulja's missed out on business opportunities while behind bars.

As we reported ... the rapper was taken into custody earlier this month after the judge said he failed to do his court-ordered community service and even conspired to falsify evidence he had completed it.

Not helping matters ... Soulja's crib in Agoura Hills was raided in February and cops found ammunition during the search. Cops had initially gone there to investigate a claim by one of his ex-girlfriends that Soulja tied her up and held her captive in his garage.

The ammunition turned out to be the start of Soulja's real troubles. Having possession of ammo is a huge no-no 'cause Soulja's on probation for a weapons case that dates back to 2014.